#!/usr/bin/tclsh set timeout -1 for { set i 1 } { $i <= 200 } { incr i } { set tpid [ spawn telnet 156.26.66.65 ] puts "2nd segment" puts $tpid expect "Password" send "cisco\r" expect ">" send "en\r" expect "Password" send "cisco\r" expect "#" sleep 3 send "exit\r" expect "Connection" exec kill -9 $tpid # proc remevid wait $tpid puts $tpid puts $i }