#!/usr/bin/expect ################################################################## # # # FileName: brg1Mb.exp # # Expect script to set wireless brdige data rate to 1 Mbps # # # ################################################################## set timeout 30 set prompt "(%|>|#|\\$) $" ; catch { set prompt $env(EXPECT_PROMPT) } set bw [lrange $argv 0 0] set dly [lrange $argv 1 1] set qlen [lrange $argv 2 2] puts "Telnet into mobile router bridge" set tpid1 [ spawn telnet 100.10.10.150 ] send "\r" expect ">" send "1" expect ">" send "1" expect ">" send "3" expect ":" send $bw send "\r" sleep 3 #send "\r" #expect ">" #send "\027" #expect ">" #send "\027" #expect ">" #send "8" #expect "?" #send "y" exec kill -9 $tpid1 puts "Telnet into Rack6R2\r" set tpid5 [spawn telnet 100.10.18.22] expect "Password" send "cisco\r" expect ">" send "en\r" expect "Password" send "cisco\r" expect "#" send "conf t\r" expect "#" send "int fa0/1\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "int fa0/0\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "end\r" expect "#" exec kill -9 $tpid5 exec route del default gw 100.10.18.22 exec route add default gw 100.10.13.7 puts "Telnet into home agent bridge" set tpid2 [ spawn telnet 100.10.10.50 ] send "\r" expect ">" send "1" expect ">" send "1" expect ">" send "3" expect ":" send $bw send "\r" sleep 1 #send "\r" #expect ">" #send "\027" #expect ">" #send "\027" #expect ">" #send "8" #expect "?" #send "y" exec kill -9 $tpid2 puts "Telnet into home agent bridge" set tpid3 [ spawn telnet 100.10.15.5 ] send "\r" expect ">" send "1" expect ">" send "1" expect ">" send "3" expect ":" send $bw send "\r" sleep 1 #send "\r" #expect ">" #send "\027" #expect ">" #send "\027" #expect ">" #send "8" #expect "?" #send "y" exec kill -9 $tpid3 puts "Telnet into home agent bridge" set tpid4 [ spawn telnet 100.10.17.5 ] send "\r" expect ">" send "1" expect ">" send "1" expect ">" send "3" expect ":" send $bw send "\r" sleep 1 #send "\r" #expect ">" #send "\027" #expect ">" #send "\027" #expect ">" #send "8" #expect "?" #send "y" exec kill -9 $tpid4 puts "Telnet into Rack7R7\r" set tpid6 [spawn telnet 100.10.13.7] expect "Password" send "cisco\r" expect ">" send "en\r" expect "Password" send "cisco\r" expect "#" send "conf t\r" expect "#" send "int fa0/0\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "int fa0/1\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "int fa1/0\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "end\r" exec kill -9 $tpid6 puts "Telnet into Rack6R7\r" set tpid7 [spawn telnet 100.10.13.77] expect "Password" send "cisco\r" expect ">" send "en\r" expect "Password" send "cisco\r" expect "#" send "conf t\r" expect "#" send "int fa0/0\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "int fa0/1\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "int fa1/0\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "end\r" exec kill -9 $tpid7 puts "Telnet into Rack7R2\r" set tpid8 [spawn telnet 100.10.14.2] expect "Password" send "cisco\r" expect ">" send "en\r" expect "Password" send "cisco\r" expect "#" send "conf t\r" expect "#" send "int fa0/0\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "int fa0/1\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "end\r" exec kill -9 $tpid8 puts "Telnet into Rack6R1\r" set tpid9 [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 "#" send "int e0/0\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "int e0/1\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "end\r" exec kill -9 $tpid9 puts "Telnet into Rack7R1\r" set tpid10 [spawn telnet 100.10.11.1] expect "Password" send "cisco\r" expect ">" send "en\r" expect "Password" send "cisco\r" expect "#" send "conf t\r" expect "#" send "int e0/0\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "int e0/1\r" send "delay " send $dly send "00" send "\r" expect "#" send "hold " send $qlen send " in\r" expect "#" send "end\r" exec kill -9 $tpid10 exec route del default gw 100.10.13.7 exec route add default gw 100.10.18.22