At 3:59 PM -0700 10/20/09, cerr wrote:
Hi,

I wanna execute an external bash command but timeout if it's taking
longer than XX seconds. I've tried it like this:
eval {
        local $SIG{ALRM} = sub {die "alarm\n"};
        alarm $timeout;
        $test = `$sshpassPATH . " -p ".$clientpw." ssh root@".$ip." ".
$RemcksumPATH." ".$RemcksumPATH." > ".$ckCKSUMclt`;

Backquotes `` create a double-quote context. You cannot use double-quotes or the concatenate operator . within that context. Put your command-line in a variable:

  my $cmd = "$sshpassPATH -p ..."

and then print the command to see what you are really trying to execute:

  print "cmd: <$cmd>\n";

and then execute it;

  $test = `$cmd`;


--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to