views:

78

answers:

2

I am trying to use Net::SFTP to get connected to remote server.

My script is:

my %args = ( 
    ssh_args => { 
       user => 'canneu_scp', 
       identity_files => [ '/home/home1/cgrshah/responsys/capgemini.private' ], 
       debug => 1, 
 } );

my $targetserver='files.responsys.net';

my $sftp = Net::SFTP->new($targetserver, %args) 
      or die "could not open connection to $targetserver\n";

But when I run this, I get an error stating:

 Not an ARRAY reference at /usr/lib/perl5/site_perl/5.8.1/Net/SFTP.pm line 36.

Can anyone help me with this?

+5  A: 

This is just a wild shot in the dark, but the user option should not be in the hash handed to ssh_args, it is at the same level. Try using this code instead:

my $sftp = Net::SFTP->new(
    $targetserver,
    user     => 'canneu_scp', 
    ssh_args => { 
        identity_files => [ '/home/home1/cgrshah/responsys/capgemini.private' ], 
        debug => 1,
    } 
) or die "could not open connection to $targetserver\n";

It sounds like the code above got you further along, and now you are having problems because your version of Math::BigInt is too old. I see three ways to move forward:

  1. switch to an RSA key instead of a DSA key
  2. find an RPM of Math::BigInt version 1.78 or later
  3. manually install a copy of Math::BigInt

The third option has many pitfalls, and if you decide to go with it I would suggest the following steps:

  1. install App::cpanminus
    1. make sure you have a gcc installed
    2. run wget -O- http://cpanmin.us | perl - --local-lib=~/perl5 App::cpanminus
    3. add ~/perl5/bin to your path
  2. install Math::BigInt into your home directory with cpanm --local-lib=~/perl5 Math::BigInt
  3. add use lib "$ENV{HOME}/perl5"; to the start of your script so it can find the new modules
Chas. Owens
yep see http://search.cpan.org/~dbrobins/Net-SFTP-0.10/lib/Net/SFTP.pm#Net::SFTP-%3Enew%28$host,_%args%29
Berov
I look in the source code of the module and it seems there on line 36 like $sftp is not an ARRAY REFhttp://cpansearch.perl.org/src/DBROBINS/Net-SFTP-0.10/lib/Net/SFTP.pm
Berov
@Berov That is the latest version, we don't know what version he or she is using. In version 0.10, there is nothing being used as an arrayref near line 36, so I am assuming that he or she is using an earlier version of a version that has been modified.
Chas. Owens
Thanks everyone for the reply.@Chas. Owens, I tried the code which you suggested.
raksha
@Chas. Owens, I tried the code you gave:I am getting the foll error:Key class 'Net::SSH::Perl::Key::DSA' is unsupported: Math::BigInt version 1.78 required--this is only version 1.70 at /usr/lib/perl5/vendor_perl/5.8.5/Crypt/DSA/KeyChain.pm line 4, <GEN0> line 1.
raksha
versions I am using are:perl-Net-SFTP-0.10-1.el4.rf, perl-Net-SSH-Perl-1.34-1.el4.rf, perl-Math-Pari-2.01080603-1.el4.rf, perl-Math-GMP-2.05-1.el4.rf. Can anyone help in how to get rid of this error??
raksha
@raksha I have updated my answer with some things to try.
Chas. Owens
A: 

hi Chas...i am the same user who asked this question. Was not able to access my account so created a new one.

Actually I am still stuck up in the same problem of Math::BigInt. Can you explain me how to exactly go for option 1: 1. switch to an RSA key instead of a DSA key