Perl/Tk Check is user is root
Posted on 2009-04-07
I have a shell script that I am converting to Perl which is used in my Perl/Tk application. It's such a simple script, that I have wasted hours failing clearly lists me for the Darwin awards. I need to check if a user is root, and if not, list that he needs root privileges before continuing. What I have that does not work is:
my $user = `whoami`;
my $uid = getpwnam("$user"); # this is not working as I would expect
if ("$uid" != 0)
print "You must be root Ian! You obtuse moron!!!\n);
My god this is so simple in shell script, how can I be screwing it up so badly???
Thanks for any thoughts!