in reply to SFTP on Windows
In order to sftp, one first has to write the code that's going to open the file on the remote server, read the local file into a buffer, then transmit the local file (one buffer at a time) to the remote server.$ret = $ssh2->scp_put($local, $remote);
See the discussion about that bug for further details.--- SSH2.pm_orig Mon Aug 23 20:06:32 2010 +++ SSH2.pm Mon Aug 23 20:36:30 2010 @@ -373,8 +373,18 @@ $self->error(0, "want $block, have $count"), return unless $count == $block; die 'sysread mismatch' unless length $buf == $count; - $self->error(0, "error writing $count bytes to channel"), retur +n - unless $chan->write($buf) == $count; + my $wrote = 0; + while ($wrote >= 0 && $wrote < $count) { + my $wr = $chan->write($buf); + last if $wr < 0; + $wrote += $wr; + $buf = substr $buf, $wr; + } + unless($wrote == $count) { + my @error = $self->error(); + warn "Error writing $count bytes to channel: @error\n"; + return; + } } # send/receive SCP acknowledgement
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: SFTP on Windows
by Limbic~Region (Chancellor) on Nov 01, 2010 at 13:17 UTC |