Cisco: Configuration save
Chuck Dock
chuckdock at mail.com
Fri Feb 6 00:20:10 CET 2004
This is the expect script that I run on my slackware box. I schedule this to run once a week via cron. Expect is part of a default slackware 9.1 full install. I also had to create a /tftpboot directory and have the tftp service running. I save the configs for over 515 routers weekly with this, made me a mini hero at my job due to the time it saves.
#!/usr/bin/expect
#
# rtrcfg.exp -- a script to perform mass configuration changes to
# a list of routers using telnet and Expect
#
#
# Set Behavior
set tftp "10.210.5.36" <<-----REPLACE with your tftp server
#
set vtypasswd xxxxxxx<<<<------REPLACE with the vty password
set enablepwd XXXXXX<<<<------REPLACE with your enable password
set aaa XXXXXXXXX<<<<<--------REPLACE with your aaa password
set userid XXX<<<<<<<----------REPLACE with your aaa username
set RTR [open "/home/chuck/programs/common_files/RTR_LIST" r] <<<<----REPLACE with a path to your router hostname list
set LOG [open "/home/chuck/programs/RESULTS/running_config_results" w] <<<---REPLACE with path to result log file
while {[gets $RTR router] != -1} {
if {[ string range $router 0 0 ] != "#"} {
set timeout 8
spawn telnet; expect "telnet>"; send "open $router\n"
sleep 2
expect {
{Username} { send "$userid\r"
expect {
{*Password*} { send "$aaa\r" }
}
}
{Password} { send "$vtypasswd\r"
expect {
{*>*} {send "enable\r"
expect {
{*Password*} { send "$enablepwd\r" }
}
}
}
}
}
#
expect {
{*#} { puts $LOG "$router - enable login ok" }
{*>} { puts $LOG "$router - failed-wrong enable"
close; wait; continue
}
timeout { puts $LOG "$router - Wrong password-failed"
close; wait; continue
}
}
# CMDs
set timeout 18
send "copy running-config tftp\r"
sleep 2
send "$tftp\r"
sleep 1
send "$router\r"
sleep 1
send "\r"
expect {
{*copied*} { puts $LOG "$router - TFTP successful"}
{*OK*} { puts $LOG "$router - TFTP successful"}
timeout { puts $LOG "$router - TFTP failed"
close; wait; continue }
}
#CMDs
send "exit\r"; close; wait
}
}
close $RTR; close $LOG
--
___________________________________________________________
Sign-up for Ads Free at Mail.com
http://promo.mail.com/adsfreejump.htm
-------------------------------------------------------
The SF.Net email is sponsored by EclipseCon 2004
Premiere Conference on Open Tools Development and Integration
See the breadth of Eclipse activity. February 3-5 in Anaheim, CA.
http://www.eclipsecon.org/osdn
_______________________________________________
Nagios-users mailing list
Nagios-users at lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/nagios-users
::: Please include Nagios version, plugin version (-v) and OS when reporting any issue.
::: Messages without supporting info will risk being sent to /dev/null
More information about the Users
mailing list