CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
script to backup a Cisco switch config to TFTP



Jun 25, 2010, 3:14 PM

Post #1 of 2 (1712 views)
script to backup a Cisco switch config to TFTP Can't Post

I'm trying to write a script that will log into a Cisco switch and copy it's config to a tftp server. What I'm struggling with is that some of the commands have special characters.

For example, here is how it would normally be done:

noc#copy run tftp 
Address or name of remote host []?
Destination filename [running-config]? noc.config
4199 bytes copied in 0.920 secs

Here is my script:


use Net::Telnet;

my $user = "back";
my $pass = "back";
my $enable = "pass";
my $tftp = '';
my $device = '';

use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,Errmode=>'die');
$telnet->waitfor('/Username: $/i');
$telnet->waitfor('/Password: $/i');
$telnet->waitfor('/Password: $/i');
print ("WAIT1\n");
print ("WAIT2\n");
$telnet->print('copy run tftp');
print ("WAIT3\n");
$telnet->waitfor('/Address or name of remote host []? $/i');
print ("WAIT4\n");
print ("WAIT5\n");
$telnet->waitfor('/Destination filename [running-config]? $/i');
print ("WAIT6\n");

I'm fairly certain it's the "[", "]" and "?" that is messing with me as perl interprets those as something special. I even have placed a "\" at the lead of each of them, but I'm still getting "pattern match timed-out at line 27". Net::Telnet is doing exactly what's it's supposed to do. No problems with that.

Any Ideas?


Jun 28, 2010, 1:02 AM

Post #2 of 2 (1669 views)
Re: [TheBigAmbulance] script to backup a Cisco switch config to TFTP [In reply to] Can't Post

Please read

Specially part


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives