Hi,

I am relatively new to perl and I am attempting to get a script working that uses SFTP. The script I am using is:

#!/usr/bin/perl -w use Net::SFTP; my $host = "10.10.10.10";<br> my %args = (<br> user => 'user',<br> password => 'pass',<br> debug => 'false'<br> ); my $sftp = Net::SFTP->new($host, %args);<br> print "connected!"; $sftp->get("/tmp/tmp/test2.txt", "/home/advserv/sean/test2.txt");
When I run this script, it only works intermittently, i.e. sometimes it works fine, but more often then not, I get the folllowing error:
# ./sftp2.pl<br> advlogs: Reading configuration data /home/advserv/.ssh/config<br> advlogs: Reading configuration data /etc/ssh_config<br> advlogs: Connecting to 10.10.10.10, port 22.<br> advlogs: Remote version string: SSH-2.0-OpenSSH_4.1 advlogs: Remote protocol version 2.0, remote software version OpenSSH_ +4.1<br> advlogs: Net::SSH::Perl Version 1.30, protocol version 2.0.<br> advlogs: No compat match: OpenSSH_4.1.<br> advlogs: Connection established.<br> advlogs: Sent key-exchange init (KEXINIT), wait response.<br> advlogs: Algorithms, c->s: 3des-cbc hmac-sha1 none<br> advlogs: Algorithms, s->c: 3des-cbc hmac-sha1 none<br> Segmentation Fault (core dumped)
I have the core file that is dumped if you require it.

I did try to upgrade the version of perl, and related libraries, and it doesnt seem to make a difference. I did come across something strange though (as an aside). Before I upgraded, the perl version was:

# perl -v This is perl, v5.6.1 built for sun4-solaris-64int (with 48 registered patches, see perl -V for more detail)
I then upgraded to:
# perl -v This is perl, v5.10.0 built for sun4-solaris
This didnt fix my SFT problem above, but another thing I saw was that the perl version is the latest when I run "perl -v" as user root (which is the user that installs the various perl libraries), but it is still the older version when I run "perl -v" as another user. This particular user is the user that owns and runs the sftp script above.

Any ideas what is happening? If you need any more info off me, just let me know.

Thanks.


Update:

Hi Guys,

Just to let you know your comments were very helpful. I am now using Net::SFTP::Foreign and it is working very well. I too had problems with libssh2, so I didnt persue the Net::SSH2 option.

I have alos got my PATH Environment Variables sorted out now, so all users using latest version of perl.

Thanks again for the help.


In reply to SFTP perl script by Anonymous Monk

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.