What is the difference between spawn and exec?

后端 未结 4 1547
-上瘾入骨i
-上瘾入骨i 2021-02-04 01:50

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 th

4条回答
  •  眼角桃花
    2021-02-04 02:05

    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.

提交回复
热议问题