#!/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"; }