Skip Menu |

This queue is for tickets about the Net-SFTP CPAN distribution.

Report information
The Basics
Id: 4715
Status: rejected
Priority: 0/
Queue: Net-SFTP

People
Owner: Nobody in particular
Requestors: mikedshelton [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: (no value)
Fixed in: (no value)



Subject: Net::SFTP->new(...) does not provide a [timeout] like Net::FTP->new() does
Net::SFTP 2.06 Perl version 5.6.0 Unix SCO_SV 3.2 5.0.5 i386 When trying to make a connection Net::SFTP->new() does not allow for a timeout when a response is not received from remote host. This code allows for a no-response, allowing program to hang forever: <code> eval { $sftp = Net::SFTP->new( $host, "user"=>$user, "password"=>$password, debug=>$debug ) ; }; if ( $@ ) { #handle error opening connection chomp( $@ ); writeLog( "Error: $@ trying to connect to remote $host" ); </code> This code captures a timeout: <code> 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); </code>