Reputation: 2633
I have been playing with Expect/TCL today and I was hoping someone can tell me why the script below fails with:
: command not found
./expect3: line 3: send: command not found
#!/usr/bin/expect -f
send " we are going to open up a file for reading, ok? \n"
expect "ok"
set fileopen [open "/home/aaron/text.txt" "r"]
set a [read $fileopen]
send "i am expecting to see a string from the file here $fileopen"
close $fileopen
Both the send and close commands fail, yet other scripts I had written with a spawn command seem to work fine?
Upvotes: 2
Views: 11900
Reputation: 84343
The main problem is that you aren't separating your commands properly. Commands in TCL must be separated by newlines or semi-colons.
In general, you should only have one Expect or TCL command per line, unless you have a properly-formed compound statement. For example, this revised snippet will work:
#!/usr/bin/expect -f
send "We are going to open up a file for reading, ok?\n"
expect "ok"
because the send and expect commands are separated by newlines.
http://tmml.sourceforge.net/doc/tcl/Tcl.html
Upvotes: 1