Re: [Ssh-sftp-perl-users] SFTP->get function failing
Brought to you by:
dbrobins
From: Rajnikant <raj...@pe...> - 2008-05-26 13:37:54
|
Thanks Fredrik. I'm using Perl v5.8.8. The thing is, this is very basic code for SFTP. I have strong gut feeling of going wrong somwhere :(. Can some one share his experience about SFTP->get function? ~~~~~~~~~~~~~~~~~~~~ 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 2:51 PM To: raj...@pe... Subject: Re: [Ssh-sftp-perl-users] SFTP->get function failing Whatever floats your boat is correct i guess ;) foreach(@files) { chomp($_); &log("Transfering $ldir\/$_ with destination $ddir\/$_"); $i = $sftp->put("$ldir/$_","$ddir/$_"); &crash("Transfer aborted <$ddir>: no such file/directory or no permissions",$ldir) if !defined($i); &log("Transfer complete..."); } and such.. This is perl, v5.8.5 on Linux hostname 2.6.9-67.0.7.ELsmp #1 SMP (RH ES) On Mon, May 26, 2008 at 11:02 AM, <raj...@pe...> wrote: > > 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? > > > ~ 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. > > 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. |