Thread: [Ssh-sftp-perl-users] SFTP->get function failing
Brought to you by:
dbrobins
From: <raj...@pe...> - 2008-05-26 07:30:33
|
Hello everyone, I'm studying SFTP. I have sample program to transfer files across two machines written in Perl. Some how my SFTP->get function is failing, but the file I'm trying to get from server is getting copied on client. Following is the code snipet: #!/usr/bin/perl use Net::SFTP; my $host = 'xx.yy.zz.aa'; # User name and password my %args = ( "user", 'user1', "password", 'password1' ); my $localFilename = 'local.txt'; my $remoteFilename = 'remote.txt'; # Creating the SFTP connection my $sftp = Net::SFTP->new($host,%args); # sftp object and connection get created successfully # Downloading file now if(!$sftp->get($remoteFilename,$localFilename)) { my $err = $sftp->status(); # $err gets 0 value print (" Get failed"); } Do anyone have any clue why my get function is failing? I'm using perl 5.8.6 on Fedora core 4. Thanks in advance. ~ Regards, Rajnikant Jachak DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. |
From: Rajnikant <raj...@pe...> - 2008-05-26 09:24:28
|
Thanks Fredrik for your reply. After reading your reply I again tried debugging same issue, but still I'm facing same problem :(. But if I changed that 'If condition' as 'if(!defined ($sftp->get($remoteFilename,$localFilename))' then everything works fine. Which is the correct way to put condition in this case? Could you please share Perl version and unix flavor where you ran this test program? ~~~~~~~~~~~~~~~~~~~~ Thanks and Best regards, ~ Rajnikant Software Engg. Persistent Sys. Ltd. Ph. +91 98222 04088 -----Original Message----- From: Fredrik Stridfeldt [mailto:str...@gm...] Sent: Monday, May 26, 2008 1:22 PM To: raj...@pe... Subject: Re: [Ssh-sftp-perl-users] SFTP->get function failing Your sample works fine. [fredriks@REMOTEHOST]$ ls -l remote.txt -rw-r--r-- 1 fredriks fredriks 24 May 26 09:43 remote.txt [fredriksf@LOCALHOST ~]$ ls -l local.txt ls: local.txt: No such file or directory [fredriks@LOCALHOST ~]$ perl testftp.pl <---- (your sample) Get failed <--- (get failed not true) [fredriks@LOCALHOST ~]$ ls -l local.txt -rw-r--r-- 1 fredriks fredriks 24 May 26 09:43 local.txt -- my $err = $sftp->status(); # $err gets 0 value -- <- is not true /F On Mon, May 26, 2008 at 9:30 AM, <raj...@pe...> wrote: > Hello everyone, > > I'm studying SFTP. I have sample program to transfer files across two machines written in Perl. Some how my SFTP->get function is failing, but the file I'm trying to get from server is getting copied on client. > > Following is the code snipet: > #!/usr/bin/perl > use Net::SFTP; > > my $host = 'xx.yy.zz.aa'; > # User name and password > my %args = ( > "user", 'user1', > "password", 'password1' > ); > > my $localFilename = 'local.txt'; > my $remoteFilename = 'remote.txt'; > > # Creating the SFTP connection > my $sftp = Net::SFTP->new($host,%args); # sftp object and connection > get created successfully > > # Downloading file now > if(!$sftp->get($remoteFilename,$localFilename)) > { > my $err = $sftp->status(); # $err gets 0 value > print (" Get failed"); > } > > Do anyone have any clue why my get function is failing? > I'm using perl 5.8.6 on Fedora core 4. > > Thanks in advance. > > ~ Regards, > Rajnikant Jachak > > DISCLAIMER > ========== > This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. > > ---------------------------------------------------------------------- > --- This SF.net email is sponsored by: Microsoft Defy all challenges. > Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. |
From: Rajnikant <raj...@pe...> - 2008-05-27 08:54:40
|
I think I got my mistake. After 'get' method call I'm getting sftp->status as 0 which is 'No Error' :). So I modified my code as below: $sftp->get($Remote,$Local); if($sftp->status) { print(" Get method failed"); return ; } else { print(" Got the file from remote"); } Do anyone see anything wrong in this code? Thanks. ~~~~~~~~~~~~~~~~~~~~ Thanks and Best regards, ~ Rajnikant Software Engg. Persistent Sys. Ltd. Ph. +91 98222 04088 -----Original Message----- From: Fredrik Stridfeldt [mailto:str...@gm...] Sent: Monday, May 26, 2008 1:22 PM To: raj...@pe... Subject: Re: [Ssh-sftp-perl-users] SFTP->get function failing Your sample works fine. [fredriks@REMOTEHOST]$ ls -l remote.txt -rw-r--r-- 1 fredriks fredriks 24 May 26 09:43 remote.txt [fredriksf@LOCALHOST ~]$ ls -l local.txt ls: local.txt: No such file or directory [fredriks@LOCALHOST ~]$ perl testftp.pl <---- (your sample) Get failed <--- (get failed not true) [fredriks@LOCALHOST ~]$ ls -l local.txt -rw-r--r-- 1 fredriks fredriks 24 May 26 09:43 local.txt -- my $err = $sftp->status(); # $err gets 0 value -- <- is not true /F On Mon, May 26, 2008 at 9:30 AM, <raj...@pe...> wrote: > Hello everyone, > > I'm studying SFTP. I have sample program to transfer files across two machines written in Perl. Some how my SFTP->get function is failing, but the file I'm trying to get from server is getting copied on client. > > Following is the code snipet: > #!/usr/bin/perl > use Net::SFTP; > > my $host = 'xx.yy.zz.aa'; > # User name and password > my %args = ( > "user", 'user1', > "password", 'password1' > ); > > my $localFilename = 'local.txt'; > my $remoteFilename = 'remote.txt'; > > # Creating the SFTP connection > my $sftp = Net::SFTP->new($host,%args); # sftp object and connection > get created successfully > > # Downloading file now > if(!$sftp->get($remoteFilename,$localFilename)) > { > my $err = $sftp->status(); # $err gets 0 value > print (" Get failed"); > } > > Do anyone have any clue why my get function is failing? > I'm using perl 5.8.6 on Fedora core 4. > > Thanks in advance. > > ~ Regards, > Rajnikant Jachak > > DISCLAIMER > ========== > This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. > > ---------------------------------------------------------------------- > --- This SF.net email is sponsored by: Microsoft Defy all challenges. > Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > _______________________________________________ > Ssh-sftp-perl-users mailing list > Ssh...@li... > https://lists.sourceforge.net/lists/listinfo/ssh-sftp-perl-users > DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails. |