Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: What is the best way to find username running your script? (Windows)

by tye (Cardinal)
on Nov 21, 2012 at 20:44 UTC ( #1005004=note: print w/ replies, xml ) Need Help??


in reply to What is the best way to find username running your script?

I use $ENV{USERNAME} because it works on Unix and on Windows, IME. $ENV{LOGNAME} is probably the oldest one on the Unix side and so may be the most widely supported. You can even use something like $ENV{LOGNAME} || $ENV{USERNAME} || $ENV{USER} (assuming you don't let anybody have a username of "0").

Of course, if you are worried about preventing people from pretending to be somebody else, then you shouldn't rely on an environment variable.

- tye        


Comment on Re: What is the best way to find username running your script? (Windows)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (6)
As of 2015-07-31 10:26 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 (276 votes), past polls