2

I am using perl, v5.10.1 on my Linux Ubuntu machine. I tried to install Net::SFTP module through cpan prompt but its giving the below errors for past 2 days.

warning:

Warning: no success downloading
'/root/.cpan/sources/authors/01mailrc.txt.gz.tmp19821'. Giving up on
it. at /usr/share/perl5/CPAN/Index.pm line 225

error:

Connecting to www.perl.org|207.171.7.51|:80... failed: Connection
timed out.

Connecting to www.perl.org|207.171.7.41|:80... failed: Connection
timed out.

Then I installed it by tar file method through CPAN site. now when I run the below sample script its throwing me the error.

script:

use Net::SFTP;

my $host = "169.144.106.231";
my %args = ( 
        user => "root",
        password => "******" );

my $sftp = Net::SFTP->new($host, %args);

Error:

Can't locate Net/SSH/Perl/Buffer.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/local/share/perl5/Net/SFTP/Buffer.pm line 6.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Net/SFTP/Buffer.pm line 6.
Compilation failed in require at /usr/local/share/perl5/Net/SFTP/Attributes.pm line 7.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Net/SFTP/Attributes.pm line 7.
Compilation failed in require at /usr/local/share/perl5/Net/SFTP.pm line 8.
BEGIN failed--compilation aborted at /usr/local/share/perl5/Net/SFTP.pm line 8.
Compilation failed in require at ankur_sftp.pl line 6.
BEGIN failed--compilation aborted at ankur_sftp.pl line 6.

I don't have Net/SSH/Perl/Buffer.pm installed and few modules like Buffer.pm are residing at some other path.

/root/Net-SFTP-0.10/blib/lib/Net/SFTP/Buffer.pm
/root/Net-SFTP-0.10/lib/Net/SFTP/Buffer.pm

My @INC contains

/usr/local/lib64/perl5
/usr/local/share/perl5
/usr/lib64/perl5/vendor_perl
/usr/share/perl5/vendor_perl
usr/lib64/perl5
/usr/share/perl5

Can anyone please help here? Why is cpan prompt method is throwing that error? Next for tar file method if there is module dependency issue then how to resolve it using CPAN tar file method? Also how to install the modules on the correct path because I don't want to add all the required module's paths in @INC path in the beginning of my script. I am a root user here.

Biffen
  • 6,249
  • 6
  • 28
  • 36
KnowledgeSeeeker
  • 620
  • 1
  • 9
  • 14
  • You haven't properly installed the Net::SFTP module. Fix the problem that is preventing CPAN from working, then use it. –  May 30 '14 at 07:28
  • use [Net::SFTP::Foreign](https://metacpan.org/pod/Net::SFTP::Foreign) that is available in Ubuntu as libnet-sftp-foreign-perl. It also provides a compatibility API (Net::SFTP::Foreign::Compat) that mimics Net::SFTP one. – salva Jun 09 '14 at 07:44

1 Answers1

3

Can't locate Net/SSH/Perl/Buffer.pm

That means the Net::SSH::Perl::Buffer module is missing. You need to install it.

Net/SFTP/Buffer.pm is not same as Net::SSH::Perl::Buffer.

You're facing the dependency issue, either you will have to go to CPAN and download tar file and install module, and you will have to do this for each missing module. I would suggest you to try CPAN client, or App::cpanminus so that the dependencies can be installed automatically.

For that see this: Installing perl dependency automatically in perl

I don't want to add all the required module's paths in @INC path in the beginning of my script

Then make sure the @INC contains the path where your modules are getting installed. You can tell it by

export PERL5LIB=/home/foobar/code (For Linux) (Add this to ~/.bashrc to make it always available when you log-in.)

set PERL5LIB = c:\path\to\dir (For Windows)

Community
  • 1
  • 1
Chankey Pathak
  • 21,187
  • 12
  • 85
  • 133
  • Thanks....I did what u told..My @INC contains required paths now (/roo/Net-SSH-Perl-1.37/blib/lib & /root/Net-SFTP-0.10/blib/lib) but it is still showing the error. – BEGIN failed--compilation aborted at /root/Net-SSH-Perl-1.37/blib/lib/Net/SSH/Perl/Util/SSH2MP.pm line 6. Compilation failed in require at /root/Net-SSH-Perl-1.37/blib/lib/Net/SSH/Perl/Util.pm line 56. and lots more for other modules... – KnowledgeSeeeker May 30 '14 at 11:51
  • Check the line where it is giving error. I think there will be a require/use line for a module, which will be missing. So you need to install that also. – Chankey Pathak May 30 '14 at 12:16