spawn和exec有什么区别? [英] What is the difference between spawn and exec?

查看:77
本文介绍了spawn和exec有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在学习编写TCL(期望)脚本,并且我注意到一些示例显示了使用spawn,而其他示例显示了命令exec.我尝试使用Google搜索,但是找不到什么区别?

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?

假设我在一个期待已久的脚本中调用"exec",那么我会发生什么?

Suppose I call 'exec' in a middle of a long expect script, what can I expect to happen?

推荐答案

spawnexpect命令,而不是tcl命令. exectcl命令.

spawn is an expect command not a tcl command. exec is a tcl command.

spawn创建一个进程.进程的输入和输出已连接到期望值,以供其他期望命令使用:sendexpectinteract.

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在tcl下创建一个子进程.通常,tcl被挂起,直到子进程完成.但是,可以在后台创建子流程(使用&作为最后一个参数),如果一个人正确地连接了输入和输出,则tcl可以与该子流程进行交互.这非常笨拙,而正是这种旨在顺利处理的交互方式.

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.

这篇关于spawn和exec有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆