#!/usr/bin/expect -- ########################################################## # # # Filename: Fore12Home.exp # # An expect script to move the mobile router from # # Home agent to Foreign Agent # # # ########################################################## # set expect timeout value set timeout 30 # set the prompt that expect uses to know if the other side is waiting # for a command set prompt "(%|#|\\$) $" ; catch {set prompt $env(EXPECT_PROMPT) } # Telnet into Mobile Router Access Point and change SSID puts "Telnet into MobielRtr" # spawn telnet session set tpid1 [ spawn telnet 100.10.10.150 ] # send a carriage return send "\r" # wait for the prompt expect ">" # send selection sleep 1 send "1" #sleep 2 expect ">" sleep 1 send "1" #sleep 2 expect ">" sleep 1 send "1" # wait a while #sleep 2 # send new SSID expect ">" sleep 2 send "home\r" sleep 1 # Send escape character twice to return to the main menu send "\027" sleep 2 send "\027" expect ">" send "8" expect "?" send "y" # Kill the telnet session exec kill -9 $tpid1 exec route del default gw 100.10.18.22 exec route add default gw 100.10.13.7 # Telnet into router Rack7R7 and configure static route puts "Telnet into Rack7R7" set tpid2 [ spawn telnet 100.10.13.7 ] expect "Password" send "cisco\r" expect ">" send "en\r" expect "Password" send "cisco\r" expect "#" send "configure terminal\r" expect "(config)#" send "no ip route 100.10.18.8 255.255.255.255 fastethernet1/0\r" expect "#" send "end\r" expect "#" # send "exit\r" exec kill -9 $tpid2 # Telnet into Rack6R7 and configure static route puts "Telnet into Rack6R7" set tpid3 [ spawn telnet 100.10.13.77 ] expect "Password" send "cisco\r" expect ">" send "en\r" expect "Password" send "cisco\r" expect "#" send "configure terminal\r" expect "(config)#" send "no ip route 100.10.18.8 255.255.255.255 fastethernet0/1\r" expect "#" send "end\r" expect "#" # send "exit\r" exec kill -9 $tpid3 # Telnet into Rack7R2 and set static route puts "Telnet into Rack7R2" set tpid4 [ spawn telnet 100.10.14.2 ] expect "Password" send "cisco\r" expect ">" send "en\r" expect "Password" send "cisco\r" expect "#" send "configure terminal\r" expect "(config)#" send "no ip route 100.10.18.8 255.255.255.255 fastethernet0/0\r" expect "#" send "end\r" expect "#" exec kill -9 $tpid4 # Telnet into Rack6R1 and reset static route puts "Telnet into Rack6R1" set tpid5 [ spawn telnet 100.10.16.11 ] expect "Password" send "cisco\r" expect ">" send "en\r" expect "Password" send "cisco\r" expect "#" send "conf t\r" expect "(config)#" send "no ip route 100.10.18.8 255.255.255.255 e0/0\r" expect "#" send "end\r" expect "#" exec kill -9 $tpid5 exec route del default gw 100.10.13.7 exec route add default gw 100.10.18.22