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?
I *believe* you need a different plan, backticks block the current process so there is no way for your Perl program to wait and then exit or similar in a timeout fashion using the backticks. For more about your options take a look at,
perldoc perlipc
That should give you some more ideas. I suspect you are going to have to use some kill mechanism with the underlying process since it doesn't implement the timeout. So you end up forking the process, waiting for the exit value in a loop, if it doesn't come before your timeout then you kill it and move on.
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>