【发布时间】:2013-09-19 05:50:57
【问题描述】:
我正在开发一个脚本,用于对软件安装进行回归测试。期望代码如下。在浏览并同意许可文件的情况下,前几行代码运行良好。但是,脚本在“请输入有效许可证文件的路径名:”处停止,并且不执行任何操作。 (注:手动安装顺利进行)。
另外,请注意所有输入的光标始终位于显示文本的右侧;但在最后一个提示(“请输入有效许可证文件的路径名:”)的情况下,光标位于文本下方和下面的行中。我不确定这是否与问题有关。
我做错了什么?我该如何调试这个问题?感谢大家的帮助。
谢谢 纳齐尔
代码如下:
#!/usr/bin/expect
spawn ./temp
expect {
"More--*" {
send " "
exp_continue
}
"Do you accept this license agreement?*" {
send "yes\r"
}
}
expect "Do you want to use the default path?*" { send "yes\r" }
expect "This load path does not exist. Do you want to create it?*" { send "yes\r" }
expect "Please enter the pathname to a valid license file:*" { send "/path_to_file\r" }
interact
下面是输出的样子:
.....(license stuff)
Do you accept this license agreement? [no] yes
Please specify where the xxx software will be loaded.
The default location is /usr/local/aaa.
Do you want to use the default path? [yes] yes
The software will not run without a valid license file installed.
Please enter the pathname to a valid license file:
【问题讨论】:
-
您在
send "/path_to_file"的末尾缺少\r。这是在真正的脚本中还是这里的复制错误? -
嗨 Barnar...谢谢指出...这是一个复制错误,我已更正。