Skip Menu |

This queue is for tickets about the Net-SFTP CPAN distribution.

Report information
The Basics
Id: 4610
Status: resolved
Priority: 0/
Queue: Net-SFTP

People
Owner: Nobody in particular
Requestors: mikedshelton [...] hotmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: SFTP->Get(), SFTP->Put() does not return a status
Net::SFTP 2.06 Perl version 5.0.6 Unix After opening an sftp connect, put() does not return a status (success or failure) upon execution as happens with $ftp->put(). While more elegant solutions may exist, it was necessary to use the following snippet to catch file transfer errors: # $sftp->put() does not have a return value on success/failure. # NOTHING GETS STORED IN $@ or $! # no warnings eliminates "Use of uninitialized value in string ne at # sftp-file-send.plx line ..." error no warnings; #wrapping eval in if compared to 0 else die if (eval{$sftp->put( $file, $target_file, \&callback );} ne 0 ) { writeLog( "* * * ABNORMAL COMPLETION * * * Unable to SFTP $filename to $target_dir on remote machine $host (check log $log_file for additional information)" ); use warnings; # $@ SHOULD HOLD ERRORS CAUGHT AS PART OF EVAL ABOVE BUT DOES NOT unlike eval { $sftp = Net::SFTP->new( $host, "user" => $user, "password" => $password, debug => $debug ); }; if ( $@ ) { #handle error opening connection chomp( $@ ); writeLog( "* * * ABNORMAL COMPLETION * * * Error: $@ trying to connect to remote Machine $host" ); # # # # # A similar issue occurs with $sftp->get(); I will submit this issue under separate cover. Thank You, Mike Shelton mikedshelton@hotmail.com
Subject: SFTP->Get() does not return a status
Net::SFTP 2.06 Perl version 5.6.0 Unix SCO_SV 3.2 5.0.5 i386 After opening an sftp connect, get() does not return a status (success or failure) upon execution as happens with $ftp->get(). While more elegant solutions may exist, it was necessary to use the following snippet to catch file transfer errors: It was necessary to check for the files existence on the receiving box to confirm the $sftp-get() was successfull. Thank You, Mike Shelton mikedshelton@hotmail.com
Date: Wed, 10 Dec 2003 13:52:36 -0600 (CST)
From: Dave Rolsky <autarch [...] urth.org>
To: Guest via RT <bug-Net-SFTP [...] rt.cpan.org>
Subject: Re: [cpan #4630] SFTP->Get() does not return a status
RT-Send-Cc:
On Wed, 10 Dec 2003, Guest via RT wrote: Show quoted text
> After opening an sftp connect, get() does not return a status (success or failure) > upon execution as happens with $ftp->get(). > > While more elegant solutions may exist, it was necessary to use the following snippet > to catch file transfer errors: > > It was necessary to check for the files existence on the receiving box > to confirm the $sftp-get() was successfull.
You already reported this in ticket 4610. I'm going to merge the two. -dave /*======================= House Absolute Consulting www.houseabsolute.com =======================*/
[autarch@urth.org - Wed Dec 10 14:52:42 2003]: Show quoted text
> On Wed, 10 Dec 2003, Guest via RT wrote: >
> > After opening an sftp connect, get() does not return a status
> (success or failure)
> > upon execution as happens with $ftp->get(). > > > > While more elegant solutions may exist, it was necessary to use the
> following snippet
> > to catch file transfer errors: > > > > It was necessary to check for the files existence on the receiving
> box
> > to confirm the $sftp-get() was successfull.
> > You already reported this in ticket 4610. I'm going to merge the two.
Oh, I see. 4610 is for put(), and this is for get(). I suspect this is a general problem with the code (no return status). I'll merge the tickets and change the title to something like "some methods do not indicate success or failure".
From: mario [...] neolabs.be
It already helps a lot if in the methods 'get' and 'put' the following is added: when you open a filehandle with the method do_open, check if a handle is returned, otherwise exit, e.g.: my $handle = $sftp->do_open($remote, SSH2_FXF_READ) or die "Can't open remote file $remote";