Friday, January 8, 2010

How to prevent non root to execute a perl script

Here is a short script to do that. This help me much...

# check if root
$user = `whoami`;
chomp $user;
if($user ne "root") {
 print "You must be root to execute this command. Please login as root or use sudo command!\n";
 exit;
}