Expect sounds like it is perfect for an application I am
developing. I need to automate a dialogue with an in-house
interactive tool that we use to query our symbol tables and
cross-references.
To experiment, I've built and installed Tcl 7.3, Tk 3.6, and
Expect 5.7 under hp-ux 9.01 on a 720. Expect and wish run and
seem to behave sanely however the example scripts fail as do the
simplest 3-liners that I can concoct.
Here is an illustrative example using expect interactively:
keithh%bcarh576 [110]: expect
expect1.1> spawn cat
spawn cat
19194
expect1.2> send "hello\r"
expect1.3> expect { *hello*} {print blah}
hello <- comes back immediately
expect1.4> <- prompt returns after timeout
Here is my understanding of what should have happened:
o I spawn cat and its stdin and stdout are connected to Expect
o I send some output and it goes to cat's stdin.
o Cat echoes that text back into Expect's pipe where it sits
until an expect command consumes the text and executes the
associated body.
This would mean that:
a) "hello" shouldn't have been printed at all. That string should
have been consumed.
b) "blah" should have been printed.
c) expect should have returned immediately because it found the match.
What am I doing wrong?
The example programs also complain about "Command not found" and
"Undefined variable" when they are run using "#!../expect -f".
Running ../expect interactively allows me to type in the same
commands which fail via script. An example command is exp_version
which fails when run in a script but works when I type it.
Again, any ideas what I am doing wrong?
I've just tried the C interface and it seems to work. However,
the data coming back from the client is still echoed. For example, if I
fh = exp_spawnl("cat", "cat", NULL);
write(fh, "hello1234\r", 6);
state = exp_expectl(fh, exp_glob, "hello", ST1, exp_end);
I get "hello1234\n" echoed out on the screen. This is presumably the
output from cat which expect should have consumed.
Again, what am I doing wrong?
Your help would be greatly appreciated. I'm going to keep
plonking along with the C interface but this has been an almost
fruitless past twelve hours.
Thanks for your help,
Keith Hanlan Kei...@bnr.ca Bell-Northern Research, Ottawa, Canada 613-765-4645