Loosing environment varable LOGNAME when running perl script in Solari

(imported topic written by SystemAdmin)

When running this from bigfix, environment variable LOGNAME for the userid root get lost.

I’m running on Solaris, but also need this to work for AIX

wait sh -c “/opt/sni/unix/tools/mojo -M off >/var/tmp/mojo.out 2>&1”

The script above uses the environment vatable ${logname} to check for the valid user root to run the script.

Only sysadminss and root are allowed to then the script, so the checking of the LOGNAME environment variable is required.

Is there another way to run this perl script so I don’t loose the environment varables set by the system?

(imported comment written by NoahSalzman)

Why not change the script to do something like this (pulled randomly from the intertubes):

$login = (getpwuid($>));

if (!$login == “root”)

{

die “\nYou cannot run this Perl script as user “$login”, must be ROOT!\n\n”;

}