Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

Can anyone confirm my understanding that the current CPAN version of NET::SFTP supports no form of reget, or restart/get functionality ?

If so, anyone have any suggestions for support of this feature in Perl-land that don't rely on the presence of external sftp clients ?

Steve.

Replies are listed 'Best First'.
Re: Net::SFTP and reget ?
by ikegami (Patriarch) on Nov 15, 2005 at 16:49 UTC

    Net::SFTP seems to support it:

    $sftp->do_write($handle, $offset, $data) ^^^^^^^ $sftp->do_read($handle, $offset, $copy_size) ^^^^^^^

    You can find out how big the file is on the remote end using do_stat.

      Fair point, but there's no high level reget method with the same signature as the get method (in partic. with a callback) so it'd be painful to have to perform regets with do_write

      Steve.

        All you need to do is copy the get function and edit the line my $offset = 0;

        Update: How about:

        sub get_from { my $sftp = shift; my($remote, $local, $cb, $from) = @_; ... my $offset = $from || 0; ... }

        The last argument is optional. If not supplied, get_from is the same as get. If supplied, the transfer will start at that offset. You can find out at which byte to start using stat on the local file. You'll need to make no other changes are needed.

Re: Net::SFTP and reget ?
by blazar (Canon) on Nov 15, 2005 at 16:35 UTC
    This may be of some interest to you!
      Thanks. At first sight, I can't see that it helps though. scp_get doesn't seem to support a seek.

      Maybe I'm whining about an embarrassment of riches, but it strikes me that there are a heck of a lot of overlapping CPAN modules in this area. Is it just me who's confused ?

      Steve.