Finding the current user
I know I can get this with `whoami`, but I was wondering if there was a "Perl" way to find the user who executed the script. I basically want to make it so my script is executable by normal users, but prints an error if it is not only the root user. -- Thanks, James Reynolds University of Utah Student Computing Labs [EMAIL PROTECTED] 801-585-9811
Re: Finding the current user
On Jan 5, 2006, at 5:53 PM, James Reynolds wrote: I know I can get this with `whoami`, but I was wondering if there was a "Perl" way to find the user who executed the script. I basically want to make it so my script is executable by normal users, but prints an error if it is not only the root user. The $< variable has the real user id, and $> is the effective user id. If you need more than the numeric user ID, have a look at: perldoc getpwnam perldoc User::pwent sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: Finding the current user
On Jan 5, 2006, at 6:04 PM, Sherm Pendley wrote: If you need more than the numeric user ID, have a look at: perldoc getpwnam perldoc User::pwent D'oh! getpwnam() is a function (not a module), so that should be: perldoc -f getpwnam perldoc User::pwent sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org
Re: Finding the current user
Thanks everyone! I suppose I should learn all the special variables after all... James At 7:52 PM -0500 1/5/06, Sherm Pendley wrote: On Jan 5, 2006, at 6:04 PM, Sherm Pendley wrote: If you need more than the numeric user ID, have a look at: perldoc getpwnam perldoc User::pwent D'oh! getpwnam() is a function (not a module), so that should be: perldoc -f getpwnam perldoc User::pwent sherm-- Cocoa programming in Perl: http://camelbones.sourceforge.net Hire me! My resume: http://www.dot-app.org