Training, Open Source computer languages

This is page http://www.wellho.net/forum/The-Tcl- ... guage/Help-TCL-automation-issue.html

Our email: info@wellho.net • Phone: 01144 1225 708225

 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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.

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