Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more

x
?
Solved

Using net::scp::expect modules

Posted on 2010-08-24
3
Medium Priority
?
1,156 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 250 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 feature and membership benefit!

New feature! Upgrade and increase expert visibility of your issues with Priority Questions.

Question has a verified solution.

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

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Checking the Alert Log in AWS RDS Oracle can be a pain through their user interface.  I made a script to download the Alert Log, look for errors, and email me the trace files.  In this article I'll describe what I did and share my script.
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…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

647 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