I am relatively new to perl and I am attempting to get a script working that uses SFTP. The script I am using is:
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:#!/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");
I have the core file that is dumped if you require it.# ./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 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:
I then upgraded to:# perl -v This is perl, v5.6.1 built for sun4-solaris-64int (with 48 registered patches, see perl -V for more detail)
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.# perl -v This is perl, v5.10.0 built for sun4-solaris
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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |