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

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.

Replies are listed 'Best First'.
Re^5: Not able to use Net::SFTP module.
by vinoth.ree (Monsignor) on Apr 30, 2014 at 05:27 UTC
    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.

        Hey,

        It seems you do not have root access to install perl modules. In my first rely itself I have mentioned that If you are the system administrator and want to install the module system-wide, So you could have told us that you are a normal user trying to install a module, something like that. To install perl modules locally in your home directory you need to do setup local lib directory. Follow the steps,

        1.Create directories in your home directory ~/src, ~/lib and ~/downloads

        2.Download the .tar.gz file into ~/downloads

        3.Unpack the CPAN Perl module,

        cd ~/src tar -zxvf ~/downloads/your_module.tar.gz

        4.cd ~/src/your_module/

        5. What the conventional method you do here ?

        perl Makefile.PL make make test make install

        6.Here is the change in the step of perl module installation. In perl Makefile.PL setp you need to tell perl that you want this module to be installed in your local path by specifying the PREFIX=~/lib as,

        perl Makefile.PL PREFIX=~/lib/ make make test make install

        Change your Perl scripts so that they can find the Perl module that you have installed locally.

        Then set the environment variable in .bash_rc or .profile file as export PERL5LIB=~/lib/


        All is well

      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.