Created
September 1, 2009 21:55
-
-
Save fapestniegd/179421 to your computer and use it in GitHub Desktop.
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
#!/bin/bash | |
DEVICES=("ASA01" "ASA02" "CS-ASA01") | |
CYCLADES=("hydra.example.net" "hydra.example.net" "tiamat.example.net") | |
PORTNUMBER=("7001" "7002" "7001") | |
ENABLEPASS=("obfuscated" "obfuscated" "obfuscated") | |
PAGERCMD=("terminal pager" "terminal pager" "terminal pager") | |
for idx in `seq 0 $(expr ${#DEVICES[@]} - 1)`;do | |
cat<<EOF | /usr/bin/expect | \ | |
awk '{ \ | |
if($0~"!-- END --!"){on=0;} \ | |
if(on){print $0;} \ | |
if($0~"!-- BEGIN --!"){on=1;getline;getline;getline;} \ | |
}' | tee ${DEVICES[${idx}]}.txt | |
set DEBUG 0 | |
set timeout 300 | |
spawn /usr/bin/ssh admin:${PORTNUMBER[${idx}]}@${CYCLADES[${idx}]} | |
send "\r" | |
expect { | |
"<--- More --->" { | |
send "q" | |
exit; | |
} | |
"${DEVICES[${idx}]}>" { | |
send "enable\r" | |
expect "Password:" | |
send "${ENABLEPASS[${idx}]}\r" | |
expect "${DEVICES[${idx}]}#" | |
} | |
"is being used by" { | |
exit; | |
} | |
"${DEVICES[${idx}]}#" { | |
} | |
} | |
# Disable Paging | |
send "conf t\r" | |
expect "${DEVICES[${idx}]}(config)#" | |
send "${PAGERCMD[${idx}]} 0\r"; | |
expect "${DEVICES[${idx}]}(config)#" | |
send "end\r"; | |
expect "${DEVICES[${idx}]}#" | |
send "!-- BEGIN --!\r" | |
expect "${DEVICES[${idx}]}#" | |
send "show failover\r"; | |
expect "${DEVICES[${idx}]}#" | |
send "show run\r"; | |
expect "${DEVICES[${idx}]}#" | |
send "!-- END --!\r" | |
# Re-Enable paging | |
expect "${DEVICES[${idx}]}#" | |
send "conf t\r" | |
expect "${DEVICES[${idx}]}(config)#" | |
send "${PAGERCMD[${idx}]} 24\r"; | |
expect "${DEVICES[${idx}]}(config)#" | |
send "end\r"; | |
expect "${DEVICES[${idx}]}#" | |
send "exit\r"; | |
exit; | |
EOF | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment