| |||||||||||
Help! TCL automation issue Posted by yzhang (yzhang), 29 August 2007 Here is my script,It will read per line of my two txt files(one is cmd file and another is result file) and excute command from cmd file and compare the output result with result file per line which i have already wrote,now i need to read the cmd file per line and compare with the result file with multiline which means i need to change my script to fit for the new requriment,how can i do this?I need your help my friends #!/usr/local/bin/expect -f set host [lindex $argv 0] set user [lindex $argv 1] set passwd [lindex $argv 2] set cmdfile [lindex $argv 3] set resultfile [lindex $argv 4] if { $argc != 5 } { puts "Usage: ./console host user passwd cmdfile resultfile" exit 1 } proc start { } { global cmdfile global resultfile set readcmdfile [open $cmdfile r] set readresultfile [open $resultfile r] set n 0 while { ![eof $readcmdfile] } { gets $readcmdfile line1 if { ![eof $readresultfile] } { gets $readresultfile line2 } else { break } incr n send "$line1\r" expect { $line2 {} timeout { send_user "\nCommand $line1 Failed excuted\n" exit 1 } } } puts "\r" puts "\n$cmdfile Test Passed\n" close $readcmdfile close $readresultfile } spawn telnet $host expect "login:" send "$user\r" expect "Password:" send "$passwd\r" expect "Starting Console" send "\r" expect "MAIN MENU" start Posted by admin (Graham Ellis), 30 August 2007 I have been scratching my head / looking to understand the code and the question / how it relates. Can you provide some sample data - what it uses now, and what it needs to use? Thanks!This page is a thread posted to the opentalk forum
at www.opentalk.org.uk and
archived here for reference. To jump to the archive index please
follow this link.
|
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho |