Re: [Ssh-sftp-perl-users] Put Issues with SFTP
Brought to you by:
dbrobins
From: Nigel R. <ni...@sy...> - 2011-01-02 18:12:41
|
What if you. print "$_:"; I always do that to make sure there is nothing extra on the end of whatever is in $_ I can't remember if you need to use chop to get rid of linefeeds. Just a guess. "Laslo Forro" <get...@gm...> wrote: >Is port ok? ( perhaps 22 instead of 220 ?) > >On Fri, Dec 31, 2010 at 10:38 AM, Thierry Chich ><thi...@gm...>wrote: > >> Le 30/12/2010 22:31, Scott Burks a écrit : >> >> 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, >> >> >> >> Hello Scott. >> I have more questions than answers, at this point. >> - What line number is XXXX ? >> - Why is there a while loop ? If your script work, it could overload >your >> ssh server. >> - You seem confident that @files contains real files, but I think you >> should test it before >> you try to put it on the remote server. >> >> >> >> >> >------------------------------------------------------------------------------ >> Learn how Oracle Real Application Clusters (RAC) One Node allows >customers >> to consolidate database storage, standardize their database >environment, >> and, >> should the need arise, upgrade to a full multi-node Oracle RAC >database >> without downtime or disruption >> http://p.sf.net/sfu/oracle-sfdevnl >> _______________________________________________ >> Ssh-sftp-perl-users mailing list >> Ssh...@li... >> https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users >> >> >------------------------------------------------------------------------------ >Learn how Oracle Real Application Clusters (RAC) One Node allows >customers >to consolidate database storage, standardize their database >environment, and, >should the need arise, upgrade to a full multi-node Oracle RAC database > >without downtime or disruption >http://p.sf.net/sfu/oracle-sfdevnl_______________________________________________ >Ssh-sftp-perl-users mailing list >Ssh...@li... >https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users -- Sent from my Android phone with K-9 Mail. Please excuse my brevity. |