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

In reply to Re: ssh2 open file problem by afresh1
in thread ssh2 scp problem by llass61

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.