Jump to content
  • Advertisement
Sign in to follow this  

BackUp Cisco router Config with perl Scripting

This topic is 3696 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've seen many post of such as was able to make a nearly perfect script for it. So far I have this
$hostname = '';
$password = 'service';
$remoteHostname = '';
$emailHost = '';
$sendTo = '';

use Net::Telnet;
$telnet = new Net::Telnet ( Timeout=>10,Errmode=>'die');
$telnet->waitfor('/Password: $/i');
print ("printing password");
$telnet->waitfor('/Router> $/i');
print ("getting admin rights");
$telnet->waitfor('/Password: $/i');
print ("printing password");
$telnet->waitfor('/Router#: $/i');
$telnet->print('copy running-config TFTP');
print ("running copy command");
$telnet->waitfor('/Address or name of remote host []? $/i');
print ("writing address of remote host");
($wkday,$month,$day,$time,$year) = split(/\s+/, localtime);
$telnet->waitfor('/Destination filename [router-confg]? $/i');
print ("giving date as $year/$month/$date");
$output = $telnet->waitfor('/!! $/i');
if ($output)
print ("true");
open (MAIL, "|$mailprog") || die 'Could not open mail program';
print MAIL "To: $sendto\n";
print MAIL "From: $emailhost\n";
print MAIL "Subject: CISCO LOG BACKUP ALERT\n\n";
print MAIL "Check CISCO router as the backup failed!";
close (MAIL)
print ("false");
print $output;
Problem is down at the end. When a config is backed up it either says, ... Failed blah blah or, !! Backed up Config blah blah. Then goes to a near line. The WaitFor can only read where a cursor is and not previous lines. I need some type of protection that if it fails, it will alert me. Currently, I just say if it times out(Any where) it sends to me, but that isn't how I wanted to do it. Any suggestions would be greatful. Thanks!

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!