sub openConnection { my $self = $_[0]; local $SIG{'__DIE__'} = sub {}; local $SIG{'__WARN__'} = sub {}; $self->{'sftp'} = Net::SFTP->new($::config{'ahost'}, user => $::config{'auser'}, password => $::config{'apass'}, ssh_args => [ options => [ 'ConnectTimeout 30', 'ServerAliveInterval 20', 'ServerAliveCountMax 3' ] ] ); if (!$self->{'sftp'}) { $self->{'error'} = "Unable to open SFTP connection"; return; } print "SFTP connection opened.\n"; return 1; }