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

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

Replies are listed 'Best First'.
Re^4: Not able to use Net::SFTP module.
by Anonymous Monk on Apr 29, 2014 at 17:02 UTC

    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

        This is the cpan temporary area, these modules aren't installed properly. Please don't advise anyone to do this.

        Update: fix typo.

        Appreciate your support. It worked what u told but now I have list of paths of modules which are not placed in @INC. (like math/Pari.pm, Digest/Sha1.pm) I am manually placing it using unshift but list seems endless. below is what I am doing.

        BEGIN { unshift (@INC, "/home/eankuls/.cpan/build/Net-SSH-Perl-1.37-KSvjy6/bli +b/lib"); unshift (@INC, "/home/eankuls/.cpan/build/Math-Pari-2.01080607-oiJwzq/ +blib/lib"); unshift (@INC, "/home/eankuls/.cpan/build/Math-Pari-2.01080607-oiJwzq/ +blib/lib"); unshift (@INC, "/home/eankuls/.cpan/build/Crypt-DH-0.07-B70AtC/blib/li +b"); unshift (@INC, "/home/eankuls/.cpan/build/Digest-SHA1-2.13-lHIaOb/blib +/lib"); }

        I just want to do it from starting. Could you pls suggest how can I unistall the previously installed modules and the exact list of modules which I need to run my script. This time I would prefer to download tar files from CPAN.

        Appreciate your support. It worked what u told but now I have list of paths of modules which are not placed in @INC. (like math/Pari.pm, Digest/Sha1.pm) I am manually placing it using unshift but list seems endless. below is what I am doing.

        BEGIN { unshift (@INC, "/home/eankuls/.cpan/build/Net-SSH-Perl-1.37-KSvjy6/bli +b/lib"); unshift (@INC, "/home/eankuls/.cpan/build/Math-Pari-2.01080607-oiJwzq/ +blib/lib"); unshift (@INC, "/home/eankuls/.cpan/build/Math-Pari-2.01080607-oiJwzq/ +blib/lib"); unshift (@INC, "/home/eankuls/.cpan/build/Crypt-DH-0.07-B70AtC/blib/li +b"); unshift (@INC, "/home/eankuls/.cpan/build/Digest-SHA1-2.13-lHIaOb/blib +/lib"); }

        I just want to do it from starting. Could you pls suggest how can I unistall the previously installed modules and the exact list of modules which I need to run my script. This time I would prefer to download tar files from CPAN coz other method is causing some permission problems.