Solved

Using net::scp::expect modules

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

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Join & Write a Comment

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
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…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 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

22 Experts available now in Live!

Get 1:1 Help Now