Solved

Using net::scp::expect modules

Posted on 2010-08-24
3
1,119 Views
Last Modified: 2012-05-10
Hello,

I have been searching all of google and i am unable to figure my problem out.

I am using the perl module "NET::SCP::EXPECT" in the perl script i am writing. The script will basically go into multiple Linux servers and retrieve a specific file. I am using SSH keys so i dont have to provide a password as several servers have different passwords. When i run my script i get the following. All server OS's are Linux.


Error: Bad password [Enter ] at /usr/lib/perl5/vendor_perl/5.8.8/Expect.pm line 733

Thanks for the help.


1 #!/usr/bin/perl
      2 
      3 #use strict;
      4 use warnings;
      5 use Net::SCP qw(scp iscp);
      6 use Net::SCP::Expect;
      7 use Net::SSH::Expect;
      8 
      9 
     10 $i = 0;
     11 
     12 @hosts = `cat ../cserver_list`;
     13 
     14 foreach(@hosts) {
     15 
     16 chomp($hosts[$i]);
     17         #print "Connecting to '$hosts'\n";
     18 
     19 my $scpe = Net::SCP::Expect->new(identity_file=>'/home/user/.ssh/id_rsa.pub');
     20 $scpe->scp('user@host:/dir/to/file.log','testers');
     21 
     22 $i++;
     23 
     24         }

Open in new window

1 #!/usr/bin/perl

      2 

      3 #use strict;

      4 use warnings;

      5 use Net::SCP qw(scp iscp);

      6 use Net::SCP::Expect;

      7 use Net::SSH::Expect;

      8 

      9 

     10 $i = 0;

     11 

     12 @hosts = `cat ../cserver_list`;

     13 

     14 foreach(@hosts) {

     15 

     16 chomp($hosts[$i]);

     17         #print "Connecting to '$hosts'\n";

     18 

     19 my $scpe = Net::SCP::Expect->new(identity_file=>'/home/<user>/.ssh/id_rsa.pub');

     20 $scpe->scp('<user>@host:/dir/to/file.log','testers');

     21 

     22 $i++;

     23 

     24         }

Open in new window

0
Comment
Question by:Realtime20
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
jeremycrussell earned 125 total points
ID: 33513168
Does the identity file have a pass-phrase?  I assume you can use normal scp -i /path/to/identity/file just fine?

You might try to use the host() and user() functions to set those separately.
0
 

Author Comment

by:Realtime20
ID: 33513881
Solved my issue.

once i thought about it. I am using the public key so i did not need to expect something. :)

I took the ::Expect off and it worked.

Thanks!
0
 

Author Closing Comment

by:Realtime20
ID: 33513909
The response did not really answer my question but was the only one that responded.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
I have been pestered over the years to produce and distribute regular data extracts, and often the request have explicitly requested the data be emailed as an Excel attachement; specifically Excel, as it appears: CSV files confuse (no Red or Green h…
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now