Created
April 1, 2013 23:19
-
-
Save glallen01/5288608 to your computer and use it in GitHub Desktop.
Cisco Config Extract with Expect.
From: http://pandaeatsbamboo.blogspot.com/2009/12/script-to-backup-cisco-device-config.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/expect | |
set timeout 5 | |
log_user 1 | |
# Include your hosts in the hostlist | |
set hostlist "rt01 rt02 sw01 sw02" | |
foreach host $hostlist { | |
set prompt [append $host "#"] | |
spawn telnet $host | |
expect $prompt | |
send "term len 0\r" | |
expect $prompt | |
set time [exec date \+\%y\%m\%dT\%H\%MJ] | |
set filename [append host "-" $time] | |
# The config file storage location | |
log_file /home/pandaeatsbamboo/cfgbackup/$filename | |
send "show run\r" | |
expect $prompt | |
send "exit\r" | |
log_file | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment