Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
Okay, so I have this really nasty problem and I'm getting a bit frustrated with it, which may be part of the problem, but here goes:

So there are currently two options if you want to use SCP in Perl:

  1. use Net::SCP;         # Doesn't allow passwords.
  2. use Net::SCP::Expect; # Passwords okay.

So I need to scp the files /flash/config.cfg and /flash/boot.cfg from a bunch of switches - not servers - using SCP. I can get the switch IPs, user name, and password into the script, but then it starts to run into problems.

First, I can't use Net::SCP because I can't set up keys on the switches for logistical reasons. (Many users need to use this script and in addition to certain keygen limitations on the switch, I don't want to maintain that many keypairs).

Second, Net::SCP::Expect seems to croak() after the first (successful) file transfer, and I'm having a tough time figuring out why it isn't working. There are some errors that appear, but they pile on top of each other on one line.

To complicate matters, every time one of these switches gets rebooted, the host key is regenerated. Messy...

Anyway, Net::SCP::Expect does have an error_handler method that takes a coderef, but it's unclear on what exactly is passed to that sub. I'm about to try Data::Dumper on @_ to see.

Any other ideas or suggestions? Anybody have any direct experience with this kind of thing and either Net::SCP or Net::SCP::Expect?

--J

Update: Added tags to highlight the fact that I am not using SCP to talk to a unix host, which is the source of most of the limitations in this problem.

Update 2: This has been solved. See below or click the link.


In reply to Using Perl to do SCP by Rhys

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (4)
As of 2024-03-29 07:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found