#!/usr/bin/expect proc CodecConf load { puts "I am in procedure no. $load" 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 "#" for {set codcounter 1} {$codcounter <= 12} {incr codcounter} { expect "#" switch $codec { 1 { #puts codec as g711alaw 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" expect "#" sleep 5 #call proc for } 2 { #puts codec as g711ulaw expect "#" send " return } #set timeout 40 #set set_slow {1 .2} #set prompt "(%|#|\\$) $" ; # default prompt #catch {set prompt $env(EXPECT_PROMPT) } spawn telnet 156.26.26.26 expect "Password" send "cisco\r" sleep 1 expect ">" send "show clock \r" expect ">" send "en \r" expect "Password:" sleep 1 send "cisco\r" sleep 1 expect "#" for { set counter 0 } { $counter <= 9 } { incr counter} { expect "#" send "tgn \r" send "stop \r" expect "#" send "clear conf \r" expect "#" switch $counter { 0 { # puts "Zero Load Configuration" expect "#" send "stop \r" expect "#" send "quit \r" expect "#" # calling procedure now to change config of # R10 & R11 CodecConf $counter } 1 { # puts "10 Load Configuration" expect "#" send "add ip \r" expect "#" send "rate 1000 \r" expect "#" send "length 125 \r" expect "#" send "start \r" # sleep 305 expect "#" send "quit \r" } 2 { # puts "20 Load Configuration" expect "#" send "add ip \r" expect "#" send "rate 1000 \r" expect "#" send "length 250 \r" expect "#" send "start \r" #sleep 305 expect "#" send "quit \r" } 3 { # puts "30 Load Configuration" expect "#" send "add ip \r" expect "#" send "rate 1000 \r" expect "#" send "length 375 \r" expect "#" send "start \r" #sleep 305 expect "#" send "quit \r" } 4 { # puts "40 Load Configuration" expect "#" send "add ip \r" expect "#" send "rate 1000 \r" expect "#" send "length 500 \r" expect "#" send "start \r" #sleep 305 expect "#" send "quit \r" } 5 { # puts "50 Load Configuration" expect "#" send "add ip \r" expect "#" send "rate 1000 \r" expect "#" send "length 625 \r" expect "#" send "start \r" #sleep 305 expect "#" send "quit \r" } 6 { # puts "60 Load Configuration" expect "#" send "add ip \r" expect "#" send "rate 1000 \r" expect "#" send "length 750 \r" expect "#" send "start \r" #sleep 305 expect "#" send "quit \r" } 7 { # puts "70 Load Configuration" expect "#" send "add ip \r" expect "#" send "rate 1000 \r" expect "#" send "length 875 \r" expect "#" send "start \r" #sleep 305 expect "#" send "quit \r" } 8 { # puts "80 Load Configuration" expect "#" send "add ip \r" expect "#" send "rate 1000 \r" expect "#" send "length 1000 \r" expect "#" send "start \r" #sleep 305 expect "#" send "quit \r" } 9 { # puts "90 Load Configuration" expect "#" send "add ip \r" expect "#" send "rate 1000 \r" expect "#" send "length 1125 \r" expect "#" send "start \r" #sleep 305 expect "#" send "quit \r" } default { puts "Nothing to do now :-) " } } } # for loop end here