in reply to Trying to get alarm to work...

I had almost the same problem. Here is a example that uses a perl based ping. I riped this out of some other code, but you could add your code to it and make a few adjustments.
use Net::Ping; use POSIX ":sys_wait_h"; my $doping="true"; my pid; $SIG{ALRM}=\&end_of_time; foreach $host ( @HOSTS ) { # If true ping the host 1st to see if its on the network. if ( $doping eq "true" ) { $pong = Net::Ping->new( $> ? "tcp" : "icmp", 10); (defined $pong ) or die "Can't create new ping object: $!\n"; if ( not $pong->ping($host) ) { $pong->close; print "$host --Dead--\n"; #go to next host next; } $pong->close; } ### Set alarm incase processes hang alarm $end_of_time; ### Do your Checks here $pid=....; } sub end_of_time { alarm 0; kill => $pid; print "----[ EOT Reached Killed shell process [ $shell ] for host + [ $host ]----\n"; }