> > eval { > $sftp = Net::SFTP->new($FTPHOST, user=>$FTPUSER, > password=>$FTPPASS); > local $SIG{ALRM} = sub { die "alarm\n" }; > alarm 60; > }; > > if ($@) { > &sendSNMP unless $@ eq "alarm\n"; > } > > When I run the test code with the endless while loop, the > script never > times out. Can someone explain how I miswrote my script? > > Unfortunately the hung SFTP connection is hard to reproduce > consistently, so I want to be sure my code *should* work if such a > situation occurs. Please note that the SFTP connection must > exist in an > eval() so when it dies, it does not exit my script. >
maybe try taking alarm out of the eval local $SIG{ALRM} = sub { die "alarm\n" }; alarm 60; eval { $sftp = Net::SFTP->new($FTPHOST, user=>$FTPUSER, password=>$FTPPASS); }; alarm 0; #cancel the alarm if does not hang if ($@ =~ /alarm/) { print "must be hung"; &sendSNMP; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]