in reply to Re: Not able to use Net::SFTP module.
in thread Not able to use Net::SFTP module.

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...

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

    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?.

      @Marto: I pasted my script, I pasted the error it threw, I also explained what I did, I also mentioned that I followed the steps explained by Vinoth. I wonder, what else do you need as being a beginner i don't have sufficient understanding. I advise you should go through some kinda article "How to understand a question". still I appreciate you responded.

        I obviously understand what you are asking. From experience I know what information you need to tell us to resolve the issue. For the third time, show how you installed modules, show the output, show any errors. Had you actually read How do I post a question effectively? you'd know what you need to provide.

Re^3: Not able to use Net::SFTP module.
by vinoth.ree (Monsignor) on Apr 29, 2014 at 09:34 UTC
    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

      Hi, I installed the modules using CPAN command and tried to follow the steps provided by you.

      #! usr/bin/perl BEGIN { unshift (@INC, "/home/eankuls/.cpan/build/Net-SSH-Perl-1.37-AUG9Mn/bli +b/lib/Net/SSH/Perl"); } use strict; use warnings; use Net::SFTP; use Net::SSH::Perl::Buffer; my $host = "rinacac-test.egi.ericsson.com"; my $userid = "root"; my $pwd = "red32hat"; 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"; eankuls@L9AHR43:~$ ls -ltr /home/eankuls/.cpan/build/Net-SSH-Perl-1.37 +-AUG9Mn/blib/lib/Net/SSH/Perl/Buffer.pm -r--r--r-- 1 eankuls egi 9725 Aug 10 2013 /home/eankuls/.cpan/build/N +et-SSH-Perl-1.37-AUG9Mn/blib/lib/Net/SSH/Perl/Buffer.pm

      As you can see i have added the above path where Buffer.pm lines into @INC, still it is trowing "can't locate" error. got totally confused.. please help

      error: Can't locate Net/SSH/Perl/Buffer.pm in @INC (@INC contains: /home/eank +uls/.cpan/build/Net-SSH-Perl-1.37-AUG9Mn/blib/lib/Net/SSH/Perl /etc/p +erl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/ +perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/l +ocal/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 9. BEGIN failed--compilation aborted at ankur_ftp.pl line 9.
        Hi,

        Oops! hold on a sec. In the BEGIN block you need to provide the path as below,

        #! usr/bin/perl BEGIN { unshift (@INC, "/home/eankuls/.cpan/build/Net-SSH-Perl-1.37-AUG9Mn/bli +b/lib/"); }

        Because, when you do use Net::SSH::Perl::Buffer Perl will replace :: to / and will search for Buffer.pm as Net/SSH/Perl/Buffer.pm in your @INC variable.

        I am very sure if you change the path in BEGIN block it should work for you.


        All is well