Operating System - HP-UX
1757016 Members
2100 Online
108858 Solutions
New Discussion

Couldnt get handle error while trying to create SFTP using NET::SFTP

 
priyadharshini_1
New Member

Couldnt get handle error while trying to create SFTP using NET::SFTP

Am new to Perl script...I have written the below SFTP perl script..Am getting "Couldnt get handle error:" ...Could anyone advice what needs to be done..

use warnings;
use Net::SFTP;

my $server="*.*.*.*";
my $user="user";
my $password="pwd";
my $source_path="/appl/xib_d/data/ftp/sftptest";
my $remote_path="/appl/xib202_t/data/ftp";
my $file_extn="txt";

my %args = (user => "$user", password => "$password", ssh_args => []);

my $sftp=Net::SFTP->new($server, %args) or die "could not open connection to $server\n";

my $file = $source_path . "/." . $file_extn;

$sftp->put($file, $remote_path) or die "could not upload a file\n";


exit;
1 REPLY 1
James R. Ferguson
Acclaimed Contributor

Re: Couldnt get handle error while trying to create SFTP using NET::SFTP

Hi:

> Am getting "Couldnt get handle error:"

Is that actually the full error? or do you die with your message "could not open..."?

I'm afraid that I don't use 'Net::SFTP' but rather 'Net::SFTP::Foreign' (which has less dependencies).

I also presume that your $server value is a sanitized one :-)

Regards!

...JRF...