sh script to get unix username of person executing it

Hi,

I am writing a script, and I need to incorporate some logic where I can find out the unix username of the person who is executing the script.

The issue is , a particular user could have "sesu" ed into a group id. for eg. root, and then executed the script. In that case, instead of root, the unix username would be desired eg. abc123

I tried echoing $USER , and then grepping it from /etc/groups. But for a group id there are N different users, and I cant pinpoint to the single user who executed the script.

Not sure how to proceed from here. Any pointers?

I am on AIX 5.3

Neil

No clear what you are trying to do. Try reading up on the id command and about the subject of real and effective UIDs.

Also the logname command.

Thanks all!

I used

who am i|awk '{ print $1F }'

Thanks

Why run 2 commands and a pipeline when the

logname 

command does the same thing?

How about:

echo ${SUDO_USER:-$USER}