Thread: [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. |
From: Thierry C. <thi...@gm...> - 2010-12-31 09:38:22
|
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. |
From: Laslo F. <get...@gm...> - 2011-01-02 09:38:05
|
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 > > |
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. |