#!/usr/bin/tclsh
set timeout 1

for { set i 1 } { $i <= 200 } { incr i } {
		set tpid [ spawn telnet 156.26.1.2 ]
		puts "third segment" 
		puts $tpid
	        expect "Password"
		send "cisco\r"
		expect ">"
		send "en\r"
		expect "Password"
		send "cisco\r"
		expect "#"
		sleep 2 
		send "exit\r"
		expect "Connection"
		exec kill -9 $tpid
	#	proc remevid
		wait $tpid 
		puts $tpid
		puts $i
					}

    Source: geocities.com/shezy22/code

               ( geocities.com/shezy22)