in reply to ssh2 scp problem

My first guess would be that you are first changing to 'test/out' then trying to retrieve 'test/out/file'. It seems unlikely that there exists 'test/out/test/out/file'. I would try either not changing directories or just get 'file'. I am testing to see if I can reproduce, but that sounds the most likely.

UPDATE 1: Nevermind all that. I see now that you get a $sftp object and do the opendir on that, then return to $ssh2->scp_get. However, having said that, in my test environment, I get a core dump when I scp_get so I will need to find another test environment.

UPDATE 2: I have tried it on a 32bit arch instead of 64bit and it doesn't core dump. And, even better, it works fine to transfer the file. I copied your script and just changed $host, $user and $password and copied a test file in '~/test/out/' to 'aaa.txt'.

Does it appear that it is getting the sftp handle that isn't working, or the scp_get?

Can you SFTP and scp the files with the normal commands, not using perl?

Can you try it with debug enabled?

Maybe try this?

#!/usr/bin/perl use strict; use warnings; use Net::SSH2; my $host = ''; my $user = ''; my $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/Tesia220044-20081029175508-03.txt") or die $s +sh2->error; $ssh2->disconnect();

l8rZ,
--
andrew

Replies are listed 'Best First'.
Re^2: ssh2 open file problem
by llass61 (Novice) on Oct 31, 2008 at 18:18 UTC
    Sorry about the code, I forgot to take out the opendir. I just updated it. That was part of my second question in another msg. Anyway, I tried the code that you asked and got the same thing. Here is the error msg:
    connecting to ftp.realtimeclaims.com... auth to ftp.realtimeclaims.com... Auth OK: 4 scp get libssh2_scp_recv(ss->session, path, &st) -> 0x0 -22LIBSSH2_ERROR_CHANNEL_REQUEST_DENIEDUnable to complete request for +channel-pr ocess-startup at sftp2.pl line 24. Net::SSH2::DESTROY object 0x183532c

    thanks for any help (again).
        No, I did ask someone if scp/sftp had to be enable at the remote site and was told no since it runs on SSH. About an hour ago someone told me yes, it had to be enabled. So I'm trying to figure out if that is the case or not. It sure would explain why I seem to be the only one who can't get sftp or scp to work correctly. Do you know?