Solved

Using net::scp::expect modules

Posted on 2010-08-24
3
1,127 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

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

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…
It’s 2016. Password authentication should be dead — or at least close to dying. But, unfortunately, it has not traversed Quagga stage yet. Using password authentication is like laundering hotel guest linens with a washboard — it’s Passé.
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

733 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