Operating System - HP-UX
1838135 Members
3255 Online
110124 Solutions
New Discussion

catch user's login and add it to an email in a script

 
SOLVED
Go to solution
Patrice Blanchard_2
Frequent Advisor

catch user's login and add it to an email in a script

Hi,

in a script, i want to catch to login of the user and add it to an email address so that i can do a mailx to it but i'm missing something.

EX:

elist= '???@domain.com'

mailx -s "test" $elist

is there a way to do a whoami into a variable and add this login to '@domain.com'.

regards

PB
6 REPLIES 6
Marvin Strong
Honored Contributor
Solution

Re: catch user's login and add it to an email in a script

elist=`whoami`@domain.com

should do what you need
Sanjay_6
Honored Contributor

Re: catch user's login and add it to an email in a script

Hi,

Do this,

User_id=`/usr/bin/whoami`
elist=$User_id@domain.dom

Hope this helps.

Regds
A. Clay Stephenson
Acclaimed Contributor

Re: catch user's login and add it to an email in a script

This should do it:

#!/usr/bin/sh

ELIST=$(who am i | awk '{print $1}')"@domain.com"
echo "Elist = ${ELIST}"
If it ain't broke, I can fix that.
A. Clay Stephenson
Acclaimed Contributor

Re: catch user's login and add it to an email in a script

I should add that ${LOGNAME} is probably already stuffed for you so that a simple approach would be:

ELIST="${LOGNAME}@domain.com"
If it ain't broke, I can fix that.
Lee Hundley
Valued Contributor

Re: catch user's login and add it to an email in a script

Hi,

elist=$(whoami)@domain.com

should do the trick
It is my firm belief that it is a mistake to hold any firm beliefs
Patrice Blanchard_2
Frequent Advisor

Re: catch user's login and add it to an email in a script

Thanks all, it's working.

regards

Patrice