[Ssh-sftp-perl-users] Put Issues with SFTP
Brought to you by:
dbrobins
From: Scott B. <sb...@tr...> - 2010-12-30 22:12:04
|
I have a perl script that logs into a vendor site and successfully lists the directory. But when I add the functionality to 'put' a group of files, I get the following error: "Couldn't get handle: Failure at ./blackdiamond.pl line XXX" I've tried 'put'ting the file from a loop and even hard-coating for a specific file and get the same error. But a manual sftp and put works just fine. I include the snippet of script below in hopes that someone can help me get past this error: #!/usr/bin/perl -w use warnings; use Net::SFTP; my $putdir = "/home/blackd/put"; my $server="remoteftpsite"; my $username="username"; my $password="password"; my $sshport="220"; # execute ftps to Vendor while(true) { #Get all the files in the directory @files = <$putdir/*>; #If it's empty, ignore doing anything. if(@files) { # Set up a SFTP connection and login. my $sftp = new Net::SFTP( $server, user=>$username, password=>$password, debug=>'true', ssh_args => [ port => '220' ] ) or die "Cannot Open Connection to $server"; # Loop through the files found. foreach(@files) { # SFTP the files first $sftp->put($_, ".") or die "Cannot putfile"; } } } closedir(PUTDIR); $sftp->ls('.' , sub { print $_[0]->{filename}, "\n" }); undef $sftp; Thanks for any input, Scott Burks Manager of Technical Services Trust Company of America Office : 303.705.6049 | Cell : 303.588.0594 http://www.trustamerica.com/ ONE ON ONE, JUST LIKE YOU TRUST PROVIDES CUSTODY AND TECHNOLOGY SERVICES TO FEE-BASED REGISTERED INVESTMENT ADVISORS. This message contains confidential and / or privileged information. If you are not the intended recipient, you must not use, copy, disclose or take any action based on this information, including attachments. If you are not the intended recipient, please advise the sender immediately by reply email and delete this message and any attachments. Thank you for your cooperation. |