加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

如何在“expect script”中启动shell脚本?

发布时间:2020-12-15 21:34:44 所属栏目:安全 来源:网络整理
导读:在这个期望脚本中没有连接ssh服务器,我只想在本地执行“.sh”文件,这可能吗? 例如: #!/bin/expectcommand "xxx.sh" # a command which starts a certain shell script 此外,是否可以在期望脚本中执行expect脚本? 例如: #!/bin/expectcommand "xxx.exp" #
在这个期望脚本中没有连接ssh服务器,我只想在本地执行“.sh”文件,这可能吗?

例如:

#!/bin/expect

command "xxx.sh" # a command which starts a certain shell script

此外,是否可以在期望脚本中执行expect脚本?

例如:

#!/bin/expect

command "xxx.exp" # a command which starts a certain expect script

有帮助吗?

解决方法

Expect中运行shell命令的命令是spawn.

#!/bin/expect
spawn command arg1 arg2 ...

命令可以是任何程序 – 二进制可执行文件,shell脚本,另一个期望脚本等.所以你可以这样做:

spawn xxx.sh

要么:

spawn xxx.exp

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读