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

Hi Monks, I am a new user of this site and a beginner. I installed Net::SFTP module from CPAN but when run the small server connection test script, its throwing the below error.

eankuls@L9AHR43:~$ perl ankur_ftp.pl Can't locate Net/SSH/Perl/Buffer.pm in @INC (@INC contains: /etc/perl +/usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl +5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local +/lib/site_perl .) at /usr/local/share/perl/5.14.2/Net/SFTP/Buffer.pm +line 6. BEGIN failed--compilation aborted at /usr/local/share/perl/5.14.2/Net/ +SFTP/Buffer.pm line 6. Compilation failed in require at /usr/local/share/perl/5.14.2/Net/SFTP +/Attributes.pm line 7. BEGIN failed--compilation aborted at /usr/local/share/perl/5.14.2/Net/ +SFTP/Attributes.pm line 7. Compilation failed in require at /usr/local/share/perl/5.14.2/Net/SFTP +.pm line 8. BEGIN failed--compilation aborted at /usr/local/share/perl/5.14.2/Net/ +SFTP.pm line 8. Compilation failed in require at ankur_ftp.pl line 5. BEGIN failed--compilation aborted at ankur_ftp.pl line 5.

Now, do i need to install all the required modules (like attributes.pm & buffer.pm etc) from CPAN or I am wrong elsewhere. I am working on ubuntu. Please help....Thanks

Replies are listed 'Best First'.
Re: Not able to use Net::SFTP module.
by marto (Cardinal) on Apr 29, 2014 at 06:30 UTC

    How did you install Net::SFTP? By "from CPAN" do you mean you used the cpan command to install modules along with their dependancies, or that this is where you downloaded them from. Net::SSH::Perl::Bufffer is part of Net::SSH::Perl, so it looks as thought either installation failed part way through or the dependancies for Net::SFTP have not been installed properly.

Re: Not able to use Net::SFTP module.
by vinoth.ree (Monsignor) on Apr 29, 2014 at 06:40 UTC
    Hi,

    If you downloaded .tar.gz file from cpan, then you need to download the dependencies also and need to install manually.

    The simplest way to get Perl modules installed is to use the CPAN module itself. If you are the system administrator and want to install the module system-wide, you'll need to switch to your root user. To fire up the CPAN module, just get to your command line and run this: perl -MCPAN -e shell

    If this is the first time you've run CPAN, it's going to ask you a series of questions - in most cases the default answer is fine. Once you find yourself staring at the cpan> command prompt, installing a module is as easy as, cpan> install Net::SFTP

    Update: Sorry to feed you with additional info, I faced the same problem of installing dependencies so, i am sharing that.

    If you use cpancommand, it constantly confirms installing dependencies. While this is an annoyance if you have to install a module with many dependencies, you can tell CPAN to automatically confirm the installation of dependencies.

    To do this, simply bring up a CPAN shell:

    perl -MCPAN -e shell

    Run these two commands in the CPAN shell:

    o conf prerequisites_policy follow o conf commit

    Now, exit the CPAN shell, start the CPAN shell, and try to install a module that you need. All dependencies will be automatically confirmed, downloaded and installed.

    The first line sets your dependency policy to follow rather than ask (default). The second line tells CPAN to write the changes to your user’s CPAN configuration file to make them permanent


    All is well

      Thanx a lot for your reply. I followed the steps but stll getting the same error. Here my script looks like..

      #! usr/bin/perl use strict; use warnings; use Net::SFTP; use Net::SSH::Perl::Buffer; my $host = "*************"; my $userid = "****"; my $pwd = "******"; my $f = Net::SFTP->new($host) or die "couldn't connect"; $f->login($userid, $pwd) or die "couldn't login"; print "successfully logged in\n";
      error: Can't locate Net/SSH/Perl/Buffer.pm in @INC (@INC contains: /etc/perl +/usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl +5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local +/lib/site_perl .) at /usr/local/share/perl/5.14.2/Net/SFTP/Buffer.pm +line 6. BEGIN failed--compilation aborted at /usr/local/share/perl/5.14.2/Net/ +SFTP/Buffer.pm line 6. Compilation failed in require at /usr/local/share/perl/5.14.2/Net/SFTP +/Attributes.pm line 7. BEGIN failed--compilation aborted at /usr/local/share/perl/5.14.2/Net/ +SFTP/Attributes.pm line 7. Compilation failed in require at /usr/local/share/perl/5.14.2/Net/SFTP +.pm line 8. BEGIN failed--compilation aborted at /usr/local/share/perl/5.14.2/Net/ +SFTP.pm line 8. Compilation failed in require at ankur_ftp.pl line 5. BEGIN failed--compilation aborted at ankur_ftp.pl line 5.

      beacuse of the error in very first line I installed Net::SSH::Perl::Buffer module too. But didn't work..Could you please tell me in detail what needs to be done here...

        What needs to be done is that you need to give us enough information to allow us to help. "But didn't work" isn't anything anyone can help you with. I already asked how you install modules. Please read and understand How do I post a question effectively?.

        Hi,

        marto is asking how did u install those modules ? Did you install them by downloading tar.gz or installed through cpan command ?

        If you have installed with tar.gz file it could have showed you the path where this module get installed. If the module is not installed in the shared lib path, you need to add that path into @INC variable as,

        #! usr/bin/perl BEGIN { unshift(@INC,"/path/where/installed/"); } use strict; use warnings; use Net::SFTP; use Net::SSH::Perl::Buffer; my $host = "*************"; my $userid = "****"; my $pwd = "******"; my $f = Net::SFTP->new($host) or die "couldn't connect"; $f->login($userid, $pwd) or die "couldn't login"; print "successfully logged in\n";

        If you are not sure where it get installed find it with the find command.


        All is well
Re: Not able to use Net::SFTP module.
by salva (Canon) on Apr 29, 2014 at 08:21 UTC