#File Name: scriptv2.exp
#!/usr/bin/expect --
set timeout 3
set prompt "(%|#|\\$) $" ;
catch {set prompt $env(EXPECT_PROMPT) }
puts "Telnet into R7 to put and redistribute static routes"
set tpid5 [ spawn telnet 10.10.10.7 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "conf t\r"
expect "#"
send "ip route 1.1.1.0 255.255.255.0 11.11.11.2\r"
expect "#"
send "ip route 150.10.10.0 255.255.255.0 11.11.11.2\r"
expect "#"
exec kill -9 $tpid5
puts "Telnet into Foreign Agent R2"
set tpid6 [ spawn telnet 11.11.11.2 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "conf t\r"
expect "#"
send "ip route 1.1.1.0 255.255.255.0 120.10.10.150\r"
expect "#"
send "ip route 150.10.10.0 255.255.255.0 120.10.10.150\r"
expect "#"
exec kill -9 $tpid6
puts "Telnet into Home Agent Access Point"
set tpid7 [ spawn telnet 120.10.10.100 ]
expect "]:"
send "=\r"
expect "]:"
send "s\r"
expect "]:"
send "ex\r"
expect "#"
send "ra\r"
expect "):"
send "home\r"
expect "]:"
sleep 1
send "apply\r"
exec kill -9 $tpid7
puts "Telnet into Foreign Agent Access Point"
set tpid8 [ spawn telnet 130.10.10.100 ]
expect "]:"
send "=\r"
expect "]:"
send "s\r"
expect "]:"
send "ex\r"
expect "#"
send "ra\r"
expect "):"
send "fore\r"
expect "]:"
sleep 1
send "apply\r"
exec kill -9 $tpid8
puts "Telnet into Router 7 to change static routes"
set tpid9 [ spawn telnet 10.10.10.7 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "conf t\r"
expect "#"
send "no ip route 1.1.1.0 255.255.255.0 11.11.11.2\r"
expect "#"
send "no ip route 150.10.10.0 255.255.255.0 11.11.11.2\r"
expect "#"
send "ip route 1.1.1.0 255.255.255.0 120.10.10.150\r"
expect "#"
send "ip route 150.10.10.0 255.255.255.0 120.10.10.150\r"
expect "#"
send "exit\r"
expect "#"
exec kill -9 $tpid9
               (
geocities.com/shezy22/code)                   (
geocities.com/shezy22)