in reply to Re^2: Obtaining %ENV values via su cmd
in thread Obtaining %ENV values via su cmd
But I never had to do this in a situation where "su" was being used, and I'd worry about whether one or the other %ENV setting gets "updated" or not across the "su" (with or without the "-" to invoke the new user's rc file(s)).my $username = $ENV{USER} || $ENV{LOGNAME} || `whoami`; chomp $username; # in case it came from the shell command
Having just tried it on freebsd, it looks like "whoami" definitely reports the "effective username" (i.e. the user that you "su" to); maybe the price of running the backtick command is worthwhile, considering the stability you get in return...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Obtaining %ENV values via su cmd
by chrism01 (Friar) on May 15, 2007 at 04:57 UTC |