Skip to content

Instantly share code, notes, and snippets.

@glallen01
Created April 1, 2013 23:19
Show Gist options
  • Save glallen01/5288608 to your computer and use it in GitHub Desktop.
Save glallen01/5288608 to your computer and use it in GitHub Desktop.
#!/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