in reply to Re: Perl Threads
in thread Perl Threads

Thanks for the suggestions. I've looked into alarm, and after looking at a multitude of resources have come up with this working example:

#!/usr/bin/perl -w use strict; my ($output); eval { local $SIG{ALRM} = sub {die "SSH timeout\n"}; alarm 15; $output = `/usr/bin/ssh -o ConnectTimeout=10 host.domain.com`; alarm 0; }; if ($@) { print "SSH timed out\n"; } else { print "SSH didn't time out\n"; }

Are there any problems with what I'm doing here?

- Justin

Replies are listed 'Best First'.
Re^3: Perl Threads
by ikegami (Patriarch) on Nov 06, 2007 at 22:40 UTC

    It won't work in Windows, and don't use it in threads. Otherwise, it's fine.