shan_emails has asked for the wisdom of the Perl Monks concerning the following question:

Hi All,

I need to do SFTP without user interaction (ie., giving password and input file and output path to sftp). For that i came to know NET::SFTP is the perl module is used for without user interaction.

But unfortunately i do not have that module in my unix box and i don't have the permission to install. for that i tried like downloaded that NET::SFTP and that required module NET::SSSH::Perl. even though it shows below error.

Can't locate Math/Pari.pm in @INC (@INC contains: Net/SSH/Perl Net/* /opt/perl/lib/5.8.1/PA-RISC2.0 /opt/perl/lib/5.8.1 /opt/perl/lib/site_perl/5.8.1/PA-RISC2.0 /opt/perl/lib/site_perl/5.8.1 /opt/perl/lib/site_perl . /dso/xyz/apps/perl) at Net/SSH/Perl/Util/SSH2MP.pm line 6.
BEGIN failed--compilation aborted at Net/SSH/Perl/Util/SSH2MP.pm line 6.
Compilation failed in require at Net/SSH/Perl/Util.pm line 56.
BEGIN failed--compilation aborted at Net/SFTP/Buffer.pm line 9.
Compilation failed in require at Net/SFTP/Attributes.pm line 7.
BEGIN failed--compilation aborted at Net/SFTP/Attributes.pm line 7.
Compilation failed in require at Net/SFTP.pm line 8.
BEGIN failed--compilation aborted at Net/SFTP.pm line 8.
Compilation failed in require at sftp_test_part1.pl line 9.
BEGIN failed--compilation aborted at sftp_test_part1.pl line 9.



#!/usr/local/bin/perl -w use FindBin qw($Bin); BEGIN{ unshift(@INC, 'Net'); unshift(@INC, 'Net/SFTP'); unshift(@INC, 'Net/SSH/Perl'); unshift(@INC, 'Net/SSH/Perl/Util'); } use Net::SFTP; use Net::SSH::Perl; my $host = "abc.account.com"; my %args = ( user => 'chshtst', password => '4getmenot', debug => 'true' ); my $sftp = Net::SFTP->new($host, %args); print "connected!"; $sftp->put("/from/path/file.pm", "/to/path"); print "done!\n";

Not sure what is the problem here and how to resolve it. I am using Perl 5.8.1 on Unix (HP-UX)

Thanks,
Shanmugam A.

Replies are listed 'Best First'.
Re: SFTP with out perl module
by marto (Cardinal) on Mar 29, 2012 at 13:27 UTC

    "Not sure what is the problem here and how to resolve it. I am using Perl 5.8.1 on Unix (HP-UX)"

    You don't have the module Math::Pari installed. See Yes, even you can use CPAN and local::lib. It's also worth pointing out that Perl 5.8.1 is nearly 10 years old.

Re: SFTP with out perl module
by salva (Canon) on Mar 29, 2012 at 13:31 UTC
    You can use Net::SFTP::Foreign that's far easier to install on Unix/Linux than Net::SFTP.

    For password authentication you will also have to install Expect. For public key authentication no additional modules are required.