dr.jekyllandme has asked for the wisdom of the Perl Monks concerning the following question:
I noticed that for $ENV{ LOGNAME } and $ENV{ USER }, I can changes the variable value using setenv in csh and export in bash. But getpwuid's value always gives me the correct value. So should I go with getpwuid to get the correct user that is calling the script? Is there a better way? Thank you.#!usr/bin/perl use strict; use warnings; my $logname = $ENV{ LOGNAME }; print "\$logname = $logname\n"; my $user = $ENV{ USER }; print "\$user = $user\n"; my $pwuid = getpwuid( $< ); print "\$pwuid = $pwuid\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: What is the best way to find username running your script? (Windows)
by tye (Sage) on Nov 21, 2012 at 20:44 UTC | |
|
Re: What is the best way to find username running your script?
by tobyink (Canon) on Nov 21, 2012 at 20:14 UTC | |
|
Re: What is the best way to find username running your script?
by Anonymous Monk on Nov 22, 2012 at 04:18 UTC |