Solved

Using net::scp::expect modules

Posted on 2010-08-24
3
1,133 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
Learn how to get help with Linux/Unix bash shell commands. Use help to read help documents for built in bash shell commands.: Use man to interface with the online reference manuals for shell commands.: Use man to search man pages for unknown command…
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…

724 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