【发布时间】:2018-06-22 15:57:20
【问题描述】:
我正在通过 docker 安装 Windows 应用程序,这需要一些用户输入,如 DB 设置等。我正在为这些用户输入使用期望脚本来自动化我们的安装。
但在最后一步中,我的安装需要 15-20 分钟,因为应用程序需要安装 DB 架构和其他必需元素,然后给出最终输入以按 Enter 键退出安装过程。
我该如何处理它,目前我只是让我的期望脚本等待,但是无论如何我可以处理这个并让期望脚本等待那个特定的输入“字符串匹配”?
这是我的期望脚本的样子
#!/bin/bash
expect -c '
spawn sh ./setupapp.sh
expect "PRESS <ENTER> TO CONTINUE:"
send "\r"
expect "PRESS <ENTER> TO CONTINUE:"
send "\r"
expect "PRESS <ENTER> TO CONTINUE:"
send "\r"
expect "PRESS <ENTER> TO CONTINUE:"
send "\r"
expect "PRESS <ENTER> TO CONTINUE:"
send "\r"
expect "PRESS <ENTER> TO CONTINUE:"
send "\r"
expect "Waiting here:"
send "\r"
expect "Waiting here:"
send "\r"
expect "Waiting here:"
send "\r"
expect "Waiting here:"
send "\r"
expect "Waiting here:"
send "\r"
expect "Waiting here:"
send "\r"
expect "PRESS <ENTER> TO Exit Installation:"
send "\r"
expect eof
'
我在这里使用 Waiting 让它等待 10 秒,有什么方法可以自动化并等待最后一个字符串按 Enter 退出安装。
谢谢!
【问题讨论】:
-
当然,我会看看它。谢谢你的建议。