期望超时和 return 输出而不执行剩余的命令
Expect timeout and return output without executing remaining commands
我正在尝试 运行 一个带有 ansible expect 模块的 shell 脚本,它需要 'n' 数量的响应,在某一点上我给出 tar 需要由脚本提取的文件名,因此需要一些时间,然后只有我会得到下一个提示,但是期望 returns 输出而不等待它完成并且无法 运行它后面的命令。如果它是由于超时而发生的,有没有办法增加它?请帮我解决这个问题。提前致谢。
要在使用 expect 模块时增加超时,您应该使用 timeout
参数,如 this doc 中所述。
因此,如果您希望在示例中有 300 秒的超时,如上述文档所示,您最终会得到如下内容:
- name: Case insensitve password string match
expect:
command: passwd username
responses:
(?i)password: "MySekretPa$$word"
timeout: 300
我正在尝试 运行 一个带有 ansible expect 模块的 shell 脚本,它需要 'n' 数量的响应,在某一点上我给出 tar 需要由脚本提取的文件名,因此需要一些时间,然后只有我会得到下一个提示,但是期望 returns 输出而不等待它完成并且无法 运行它后面的命令。如果它是由于超时而发生的,有没有办法增加它?请帮我解决这个问题。提前致谢。
要在使用 expect 模块时增加超时,您应该使用 timeout
参数,如 this doc 中所述。
因此,如果您希望在示例中有 300 秒的超时,如上述文档所示,您最终会得到如下内容:
- name: Case insensitve password string match
expect:
command: passwd username
responses:
(?i)password: "MySekretPa$$word"
timeout: 300