----------- ----------
| R8 | TFTP server | R9 |
| | | |
------------ -----------
| |
| |
| |
----------- -------------
| R10 | IP CLOUD | R11 |
TGN | | | | TGN traffic dest.
----------- -------------
r9#sh call act vo
r9#sh call hist vo
************************************************************************************************
Expect:
In the script shown below we have had top break it down in to smaller pieces as the Linux box does not allow for a particular process to spawn more than 256 telnet sessions. (total, not at once). Also the script is not as modular as we would have liked it to be as we were having trouble with the telnet sessions there too.
ROUTERMAIN.EXPECT:
#!/bin/expect/
exec expect /data/routerpart1.expect
sleep 2
exec expect /data/routerpart2.expect
sleep 2
exec expect /data/routerpart3.expect
sleep 2
exec expect /data/routerpart4.expect
sleep 2
exec expect /data/routerpart5.expect
sleep 2
exec expect /data/routerpart6.expect
AND SO ON.................till routerpart24.expect.
ROUTERPART1.EXPECT:
here three parts cover all the codecs for a particular load level.
like part1, part2 and part3 for load 0.
#!/usr/bin/expect
set timeout 1
proc files codecname {
#puts "am working on codec no. $codecname"
for {set filecount 1} {$filecount <= 2} {incr filecount} {
set slpdur 20
switch $filecount {
1 {
#puts file as ref-f1.au
set tpid [ spawn telnet 156.26.1.2 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "stop \r"
expect "#"
send "global type voice \r"
expect "#"
send "audio-file 1 tftp://130.10.10.100/ref-f1.au \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
for {set i 1 } { $i <= 3 } { incr i } {
switch $i {
1 {
set tpid [ spawn telnet 156.26.66.65 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "stop \r"
expect "#"
send "global type voice \r"
expect "#"
send "audio-file 1 tftp://130.10.10.100/ref-f11$codecname.au \r"
expect "#"
send "exit \r"
expect "#"
send "start \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
set tpid [ spawn telnet 156.26.1.2 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "start \r"
sleep $slpdur
expect "#"
send "stop \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
}
2 {
set tpid [ spawn telnet 156.26.66.65 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "stop \r"
expect "#"
send "global type voice \r"
expect "#"
send "audio-file 1 tftp://130.10.10.100/ref-f12$codecname.au \r"
expect "#"
send "exit \r"
expect "#"
send "start \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
set tpid [ spawn telnet 156.26.1.2 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "start \r"
sleep $slpdur
expect "#"
send "stop \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
}
3 {
set tpid [ spawn telnet 156.26.66.65 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "stop \r"
expect "#"
send "global type voice \r"
expect "#"
send "audio-file 1 tftp://130.10.10.100/ref-f13$codecname.au \r"
expect "#"
send "exit \r"
expect "#"
send "start \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
set tpid [ spawn telnet 156.26.1.2 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "start \r"
sleep $slpdur
expect "#"
send "stop \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
}
}
}
}
2 {
#puts file as ref-m1.au
set tpid [ spawn telnet 156.26.1.2 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
expect "#"
send "callgen \r"
expect "#"
send "stop \r"
expect "#"
send "global type voice \r"
expect "#"
send "audio-file 1 tftp://130.10.10.100/ref-m1.au \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
for {set i 1 } { $i <= 3 } { incr i } {
switch $i {
1 {
set tpid [ spawn telnet 156.26.66.65 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "stop \r"
expect "#"
send "global type voice \r"
expect "#"
send "audio-file 1 tftp://130.10.10.100/ref-m11$codecname.au \r"
expect "#"
send "exit \r"
expect "#"
send "start \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
set tpid [ spawn telnet 156.26.1.2 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "start \r"
sleep $slpdur
expect "#"
send "stop \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
}
2 {
set tpid [ spawn telnet 156.26.66.65 ]
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
expect "#"
send "callgen \r"
expect "#"
send "stop \r"
expect "#"
send "global type voice \r"
expect "#"
send "audio-file 1 tftp://130.10.10.100/ref-m12$codecname.au \r"
expect "#"
send "exit \r"
expect "#"
send "start \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
set tpid [ spawn telnet 156.26.1.2 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "start \r"
sleep $slpdur
expect "#"
send "stop \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
}
3 {
set tpid [ spawn telnet 156.26.66.65 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "stop \r"
expect "#"
send "global type voice \r"
expect "#"
send "audio-file 1 tftp://130.10.10.100/ref-m13$codecname.au \r"
expect "#"
send "exit \r"
expect "#"
send "start \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
set tpid [ spawn telnet 156.26.1.2 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "callgen \r"
expect "#"
send "start \r"
sleep $slpdur
expect "#"
send "stop \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
}
}
}
}
}
}
return }
# prcedure ends here
proc codecconf load {
for {set codcounter 1} {$codcounter <= 4 } {incr codcounter} {
switch $codcounter {
1 {
#puts codec as g711alaw
set codecname "noloadg711a"
set tpid [ spawn telnet 156.26.52.52 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "conf t \r"
expect "#"
send "dial-peer voice 101 voip \r"
expect "#"
send "codec g711alaw \r"
expect "#"
send "end \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
#config r11 too
set tpid [ spawn telnet 156.26.52.53 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "conf t \r"
expect "#"
send "dial-peer voice 101 voip \r"
expect "#"
send "codec g711alaw \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "#"
send "wr m \r"
sleep 5
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
#call proc for file manip on r8 and r9
files $codecname
}
2 {
#puts codec as g711ulaw
set codecname "noloadg711u"
set tpid [ spawn telnet 156.26.52.52 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "conf t \r"
expect "#"
send "dial-peer voice 101 voip \r"
expect "#"
send "codec g711ulaw \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "#"
send "wr m \r"
sleep 5
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
#config r11 too
set tpid [ spawn telnet 156.26.52.53 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "conf t \r"
expect "#"
send "dial-peer voice 101 voip \r"
expect "#"
send "codec g711ulaw \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "#"
send "wr m \r"
sleep 5
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
#call proc for file manip on r8 and r9
files $codecname
}
3 {
#puts codec as g723ar53
set codecname "noloadg723ar53"
set tpid [ spawn telnet 156.26.52.52 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "conf t \r"
expect "#"
send "dial-peer voice 101 voip \r"
expect "#"
send "codec g723ar53 \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "#"
send "wr m \r"
sleep 5
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
#config r11 too
set tpid [ spawn telnet 156.26.52.53 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
expect "#"
send "conf t \r"
expect "#"
send "dial-peer voice 101 voip \r"
expect "#"
send "codec g723ar53 \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "#"
send "wr m \r"
sleep 5
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
#call proc for file manip on r8 and r9
files $codecname
}
4 {
#puts codec as g723ar63
set codecname "noloadg723ar63"
set tpid [ spawn telnet 156.26.52.52 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
expect "#"
send "conf t \r"
expect "#"
send "dial-peer voice 101 voip \r"
expect "#"
send "codec g723ar63 \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "#"
send "wr m \r"
sleep 5
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
#config r11 too
set tpid [ spawn telnet 156.26.52.53 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "conf t \r"
expect "#"
send "dial-peer voice 101 voip \r"
expect "#"
send "codec g723ar63 \r"
expect "#"
send "exit \r"
expect "#"
send "exit \r"
expect "#"
send "wr m \r"
sleep 5
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
#call proc for file manip on r8 and r9
files $codecname
}
}
}
return
}
# puts "Zero Load Configuration"
set load "noload"
set tpid [ spawn telnet 156.26.26.26 ]
expect "Password"
send "cisco\r"
expect ">"
send "en \r"
expect "Password"
send "cisco\r"
expect "#"
send "tgn \r"
expect "#"
send "stop \r"
expect "#"
send "clear conf \r"
expect "#"
send "quit \r"
expect "#"
send "exit \r"
expect "Connection"
exec kill -9 $tpid
wait
# calling procedure now to change config of
# R10 and R11
codecconf $load
****************************************************************************************
               (
geocities.com/eureka/park/9824)                   (
geocities.com/eureka/park)                   (
geocities.com/eureka)