Operating System - HP-UX
1834480 Members
3792 Online
110067 Solutions
New Discussion

perl differences with 11iv2?

 
SOLVED
Go to solution
Steve Dorland_1
Occasional Advisor

perl differences with 11iv2?


I'm starting a script with a test for user and OS, like:

chomp($thisuser = `/usr/bin/whoami`);
chomp($thisos = `/usr/bin/uname -r`);

if($thisos ne "B.11.23") {
if($thisuser ne "root") {
print "You need to run this script as root.\n";
exit(0);
}
print "This script runs on HP-UX11.23. \n";
exit(0);
}

These tests work fine on a box running 11.11, but the user test fails to catch a non-root user on an 11.23 box. Both boxes point to the same location for the same version of Perl.

Any idea what I'm doing wrong?

Thanks!
4 REPLIES 4
Kent Ostby
Honored Contributor

Re: perl differences with 11iv2?

By any chance is your "non root" user on the 11.23 machine set up with an id of 0 ?
"Well, actually, she is a rocket scientist" -- Steve Martin in "Roxanne"
Steve Dorland_1
Occasional Advisor

Re: perl differences with 11iv2?


No, good thought, so I double-checked since I'm a sysadm, but it's as me, with a non-zero uid, that it's happening.
Don Morris_1
Honored Contributor
Solution

Re: perl differences with 11iv2?

Ok... call me nuts - but why *would* you expect this to do the user test on 11.23? uname -r should report B.11.23 if I recall correctly - so the first if() condition is FALSE (you're using ne, after all), you skip the user test and go straight to the "This script runs on HP-UX 11.23\n"; print.

If the script you have a problem with is different -- please post that script. :) Otherwise, remove the check for 11.23 or invert the order of the conditionals if you want to test for non-root on 11.23.

i.e.

if($thisuser ne "root") {
print "You need to run this script as root.\n";
exit(0);
}

if($thisos ne "B.11.23"){
print "This script runs on HP-UX 11.23.\n";
exit(0);
}
Steve Dorland_1
Occasional Advisor

Re: perl differences with 11iv2?

arg... of course. thanks!