Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to find out the Unix UID that a perl script was run as

Status
Not open for further replies.

ianfo

Programmer
Aug 20, 2002
29
GB

Hi,

I'm going to be running a perl script from different users crontabs. Is there a way within a perl script to find out what user it was run by (without calling out to something like id or "echo $LOGNAME").

Thanks.
 
$> Holds the effective UID of the currently running Perl program

$< Holds the real UID of the currently running Perl program

Hope that helps,

Will.
fortytwo
will@hellacool.co.uk
 

Is it possible to get the username rather than the UID?

Thanks
 
These might be of some help:

getpwnam($name) In a scalar context returns the UID for that login name; in a list context returns all of the fields of a password entry

getpwuid($uid) In a scalar context returns the login name for that UID; in a list context returns all of the fields of a password entry

Will.
fortytwo
will@hellacool.co.uk
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top