#notify user attempting connection writeLog( "Connecting to host : $host as user : $user" ); #open connection eval { #timeout if no response within 120 seconds $SIG{ALRM} = sub {die "Net::SFTP timed out\n"}; alarm(120); $sftp = Net::SFTP->new($host, user=>$u password=>$p debug=>1); alarm(0); }; if ( $@ ) { #handle error opening connection alarm(0); chomp( $@ ); writeLog( "Error: $@ trying to connect to remote $host"); sendEmail(); sendPage(); die("\n"); } alarm(0); writeLog("Connected to host : $host as user : $user");