Your skill will accomplish
what the force of many cannot
Using Perl to do SCPby Rhys (Pilgrim)
|on Sep 15, 2004 at 15:11 UTC||Need Help??|
Rhys has asked for the
wisdom of the Perl Monks concerning the following question:
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:
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?
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.