如何在“期望脚本"中启动Shell脚本? [英] How to start a shell script within "expect script"?
本文介绍了如何在“期望脚本"中启动Shell脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在这种期望脚本中,将没有ssh服务器连接,我只想在本地执行".sh"文件,这可能吗?
In this expect script there will be no ssh server connected, I just want to execute a ".sh" file locally, is that possible?
例如:
#!/bin/expect
command "xxx.sh" # a command which starts a certain shell script
还可以在期望脚本中执行期望脚本吗?
Also, is it possible to execute a expect script within a expect script?
例如:
#!/bin/expect
command "xxx.exp" # a command which starts a certain expect script
有帮助吗?
推荐答案
Expect中运行shell命令的命令为spawn
.
The command in Expect to run a shell command is spawn
.
#!/bin/expect
spawn command arg1 arg2 ...
command
可以是任何程序-二进制可执行文件,shell脚本,另一个Expect脚本等.因此,您可以执行以下操作:
command
can be any program -- a binary executable, a shell script, another expect script, etc. So you can do:
spawn xxx.sh
或:
spawn xxx.exp
这篇关于如何在“期望脚本"中启动Shell脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文