This is my test script for trying to get/put files using ssh2->scp_???
use strict;
use warnings;
use Net::SSH2;
my $host = 'ftp.?????.com';
my $user = 'user';
my $password = 'password';
my $ssh2 = Net::SSH2->new();
$ssh2->debug(1);
print "\nconnecting to $host...\n";
$ssh2->connect($host) or die $ssh2->error;
print "\nauth to $host...\n";
$ssh2->auth_password($user,$password) or die $ssh2->error;
printf "Auth OK: %s\n", $ssh2->auth_ok;
print "scp get\n";
$ssh2->scp_get("test/out/MyFile-03.txt") or die ssh2->error;
$ssh2->disconnect();
I also used the opensource WinSCP to test out the connections and got errors when trying to use scp.
| [reply] [d/l] |
Using your script on my Win32 box to connect to an SSH2 server on my linux box, I find that the connection is made without any trouble at all. However, the 'scp_get' call segfaults, and I get the following error message:
libssh2_scp_recv(ss->session, path, &st) -> 0x2b849a4
If I try an 'scp_put' I get a similar message (and segfault):
libssh2_scp_send_ex(ss->session, path, mode, size, mtime, atime) -> 0x
+2b8a0d4
I find that the file I tried to upload with 'scp_get' was created in the correct location on the server ... but is empty :-( The test script that ships with the Net-SSH2 source, constructs the 'scp_get' call a little differently (though that's not the problem, afaict). It does:
my $check = IO::Scalar->new;
$ssh2->scp_get($remote, $check);
I hadn't realised scp wasn't working on Windows. (I failed to notice that, since IO::Scalar was not installed, the scp tests were being skipped.) OTOH, sftp seems to work fine
I'm using Net-SSH2-0.18 on perl-5.10.
Update: Just noticed that 'scp_put' and 'scp_get' both work ok for me on perl-5.8.8, Win32. If you're using Win32, and you really do need scp, then 5.8.8 is probably the simplest way to achieve it.
Cheers, Rob | [reply] [d/l] [select] |
You might want to apply the following patch if you want to run Net::SSH2 on perl-5.10.
http://rt.cpan.org/Public/Bug/Display.html?id=36614
I got bitten by that bug also..
| [reply] |