On Dec 26, 2003, at 10:56 AM, glidden, matthew wrote:
In my current script, I'm polling machines for data, mostly by using rsh and
the backtick. For example:
my $retVal = `rsh $hostname -l root "/usr/local/blah"`;
I'd like the backticks to timeout at 30 seconds, to prevent getting stuck. I
already added a ping test before the call, but some pinged hosts get stuck
waiting at the rsh call anyway. Can I do this with the backticks or do I
need a different command here?
Have you thought about using 'alarm()'???
eg:
my $sig_child_flag=0;
my $answer;
eval {
local $SIG{ALRM} = sub { $sig_child_flag++; die "alarm\n" ;};
alarm(35);
my $cmd = q!(/usr/bin/sleep 15 ; echo "slept 15" )! ;
$answer =`rsh $host '$cmd'` ;
};
if ( $sig_child_flag )
{
print "alarm called?\n";
} else {
print $answer ;
}But you might want to get out of that rsh and think about other strategies, like putting up a mini-web-server that will take requests for you... and then get into the coolneff of having a 'web technology'.
ciao drieux
---
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>
