Debugging Expect programs

Expect seems to be particularly prone to the situation that a newcomer writes a script, doesn't get the result he or she expects, and then appears to be completely at a loss as to what to do next. This page dissolves that paralysis.

Chapter 18 of BOOK Exploring Expect is devoted to "Debugging Scripts".

One of the commonest complaints is, "... and that's the pattern I wrote, but Expect isn't doing anything ..." This is often a symptom of a failure to expect the character stream Expect actually sees. A good place to begin, therefore, is often simply to change

    expect myscript.exp


    expect -d myscript.exp

The latter invocation provides abundant information about, among other things, the output Expect tries to match. Study of -d reports frequently suffices to solve otherwise-thorny problems.

"What debugging tools are available to a Tcl programmer" includes several outstanding tips.

[exp_internal; Chapters 7, 9, 18, and page 531; ...]

[Explain crucial role of autoexpect (but see mention of interact below). Have beginners start with it.] [Pick appropriate references from FAQ.]

escargo - What I have found useful included log_file and log_user.

[Without doubt, the most useful tool for debugging expect itself is "exp_internal". It's boolean. It tells you what you got, no matter what you "expect"ed.]

[Explain importance of inserting [sleep 1] before password transmission, when all else fails.]

In clt, Don once wrote, "Try changing ... to interact. If you can do the interaction yourself, then it's just a matter of getting the scripting correct."

"Debugging Expect" [1 ]

"Expect's frequently-made mistakes"

[Explain exp_internal.]