Installation and sample of Tcl/tk

1.Download the executable file from website and install it in windows system, eg: “http://globalfilesearch.com/download.aspx?path=virtualhosts.botik.ru/rented/botik/www/download/tcl_tk_for_win/ActiveTcl8.5.0.0-win32-ix86-93230.exe”
2.Run tclsh to execute commands, here is a sample which can telnet to the DUT and set some prameters.

package require Expect
set DUTIP 192.168.0.1
set Login admin
set Password 12345678
set logfile log.txt
set dis [open $logfile w+]

puts $dis "\n"
puts $dis "##############################"
puts $dis "##          Login           ##"
puts $dis "##############################"

log_file -open $dis
spawn Telnet $DUTIP
set console_id $spawn_id
expect "Enter user:"
send -i $console_id "$Login\r"
expect "Enter password:"
send -i $console_id "$Password\r"
expect "DUT>"
#send -i $console_id "help\r"
after 1000

puts $dis "\n"
puts $dis "##############################"
puts $dis "##          Status         ##"
puts $dis "##############################"
expect "DUT>"
send -i $console_id "status\r"
expect "DUT>"
send -i $console_id "ipcable\r"
expect "DUT>"
send -i $console_id "vendor\r"
after 500


puts $dis "\n"
puts $dis "##############################"
puts $dis "##        NATmapping        ##"
puts $dis "##############################"
expect "DUT> "
send -i $console_id "setfirewallengin 1\r"
puts firewallenable
expect "DUT>"
send -i $console_id "setnat 1\r"
puts "enable NAT"
after 500
expect "DUT>"
send -i $console_id "setnatmapping 1\r"
puts "enable mapping"
after 500
expect "DUT>"
send -i $console_id "natmapping add 172.16.1.200 192.168.0.35\r"
puts "add 1 mapping"
after 1000

Thursday, October 08, 2015 | Networking

文章评论

No comments posted yet.

发表评论

Please add 8 and 1 and type the answer here: