Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
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 {

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"

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 and archived here for reference. To jump to the archive index please follow this link.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2022: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 793803 • EMAIL: • WEB: • SKYPE: wellho