Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: How do you grab username/login id in Unix?

by htoug (Deacon)
on Dec 02, 2004 at 07:04 UTC ( #411668=note: print w/ replies, xml ) Need Help??


in reply to How do you grab username/login id in Unix?

$ENV{LOGNAME} should do it in many cases. It has been defined as the username on all systems I have used.

But the getpwxxx method that gaal showed is probably the best. It should work on more than just unix.


Comment on Re: How do you grab username/login id in Unix?
Replies are listed 'Best First'.
about LOGNAME
by Luca Benini (Scribe) on Dec 02, 2004 at 07:22 UTC
    $ENV{LOGNAME} is setted at login time, so if someone log in as popeye and the do
    su
    his $ENV{LOGNAME} is again popeye. But if popoye do
    su -
    his $ENV{LOGNAME} is again popeye.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://411668]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (18)
As of 2015-07-30 18:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls