[MLB-WIRELESS] Remote Restart script help

Adrian Lodders adrianlodders at bigpond.com
Sat Jun 18 18:50:17 EST 2005


Thanks for all the help!
I've got shutdown, restart and abort commands working without a problem
with 1 minute worth of time to abort.

Right now it's using backticks that Rowan showed, but I'll have a look
at the way Dan has done it soon.

Thanks again for everyone's help, it's been awhile since I've done any
programming in PERL.

Kind regards,
	Adrian
	NodeGZX

-----Original Message-----
From: owner-melbwireless at wireless.org.au
[mailto:owner-melbwireless at wireless.org.au] On Behalf Of Dan McGarry
Sent: Saturday, 18 June 2005 11:08 AM
To: Rowan Crowe
Cc: melbwireless at wireless.org.au
Subject: Re: [MLB-WIRELESS] Remote Restart script help

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


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