[MLB-WIRELESS] Remote Restart script help

Dan McGarry it.psl at fsp.org.vu
Sat Jun 18 11:07:51 EST 2005


Rowan Crowe wrote:
> 
> Does perl let you use backticks to run a shell command?

Perl let's you do lots of things, but that doesn't always mean you 
should. 8^)

You can backtick a command, but you have to be very careful about the 
use of variables inside that command line, lest you find out that you've 
made it easy for someone else to run commands as well. You almost 
certainly want to use tainting (i.e. perl -t).

If there's another way to check the result of your command, I'd 
recommend you do it that way. The example you gave would probably work 
equally well as:

# Give yourself time to react when you shutdown
# The value here is 1 minute
$time_to_shutdown = 1;

# Hard-coded passwords are dangerous. Consider validating a
# session token instead.
if ( validate_token() ) {
   system("shutdown", "-r", "$time_to_shutdown") == 0
     or die "Couldn't shutdown: $?\n";
}

But, yes, backticks are available as an option.

-- 
Dan McGarry		it.psl at fsp.org.vu

IT Consultant/Trainer - FSP Vanuatu
Pacific Skills Link Project

To unsubscribe: send mail to majordomo at wireless.org.au
with "unsubscribe melbwireless" in the body of the message



More information about the Melbwireless mailing list