Why do I get "command not found" when running my Expect script?
Problem
The main problem is that you aren't separating your commands properly. Commands in TCL must be separated by newlines or semi-colons.
Solution
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.
See Also
http://tmml.sourceforge.net/doc/tcl/Tcl.html
DevilWAH
I am a Cisco network engineer by trade and Certifications, however always been intrestded in Programing and perfect Logic of it. Played around with Batch scripts before, but finaly have got a project worth looking in programing as a solution. So a bit of Perl, bit of PHP, VB script, VBA and now fianlly C#. Still very much hashing things togather, and with out the help from the people here would have fallen many times by now. This site has so many people willing to help and with expertise that I can only dream of one day achiving. A big thank you to you all and hope in time I will be able to start repaying with some help of my own. Devil~With~A~Halo (AKA Aaron)
Updated on June 30, 2022Comments
-
DevilWAH almost 2 years
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?