在此期望脚本中,将没有ssh服务器连接,我只想在本地执行“ .sh”文件,这可能吗?
例如:
#!/bin/expect
command "xxx.sh" # a command which starts a certain shell script
Run Code Online (Sandbox Code Playgroud)
另外,是否可以在期望脚本中执行期望脚本?
例如:
#!/bin/expect
command "xxx.exp" # a command which starts a certain expect script
Run Code Online (Sandbox Code Playgroud)
有什么帮助吗?
运行 shell 命令的 Expect 中的命令是spawn.
#!/bin/expect
spawn command arg1 arg2 ...
Run Code Online (Sandbox Code Playgroud)
command 可以是任何程序——二进制可执行文件、shell 脚本、另一个期望脚本等。所以你可以这样做:
spawn xxx.sh
Run Code Online (Sandbox Code Playgroud)
或者:
spawn xxx.exp
Run Code Online (Sandbox Code Playgroud)