I'm learning to write a TCL (expect) scripts and I notice that some examples show to use spawn, while others show the command exec. I tried googling, but can't find what is the difference?
Suppose I call 'exec' in a middle of a long expect script, what can I expect to happen?
spawn
is an expect
command not a tcl
command. exec
is a tcl
command.
spawn
creates a process. The processes' input and output are connected to expect for use by the other expect commands: send
, expect
and interact
.
exec
creates a subprocess under tcl. In general the tcl is suspended until the subprocess completes. However, one can create the subprocess in the background (using & as the last argument) and if one hooks up the input and output correctly, tcl can interact with the subprocess. This is very clumsy and is exactly the sort of interaction that expect was designed to handle smoothly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With