Linux Expect-不按需要发送文本

Linux Expect-不按需要发送文本,linux,send,expect,Linux,Send,Expect,我正在开发一个脚本,用于软件安装的回归测试。expect代码如下所示。在浏览并同意许可证文件的地方,前几行代码运行良好。但是,脚本在“请输入有效许可证文件的路径名:”处停止,并且不执行任何操作。(注意:手动安装会顺利进行) 此外,请注意,所有输入的光标始终位于显示文本的右侧;但在最后一次提示(“请输入有效许可证文件的路径名:”)的情况下,光标位于文本下方和下面的行中。我不确定这是否与这个问题有关 我做错了什么?如何调试此问题?我感谢你们所有人的帮助 谢谢 纳齐尔 代码如下: #!/usr/bin

我正在开发一个脚本,用于软件安装的回归测试。expect代码如下所示。在浏览并同意许可证文件的地方,前几行代码运行良好。但是,脚本在“请输入有效许可证文件的路径名:”处停止,并且不执行任何操作。(注意:手动安装会顺利进行)

此外,请注意,所有输入的光标始终位于显示文本的右侧;但在最后一次提示(“请输入有效许可证文件的路径名:”)的情况下,光标位于文本下方和下面的行中。我不确定这是否与这个问题有关

我做错了什么?如何调试此问题?我感谢你们所有人的帮助

谢谢 纳齐尔

代码如下:

#!/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:
以下是输出的外观:

#!/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:

您可以使用-d开关在expect中进行调试:

#!/usr/bin/expect -d

它非常冗长,帮助我记下了在expect中写作时犯下的无数小错误。

send”/path\u to\u file“
的末尾,您缺少了
\r
。这是真实的脚本还是复制错误?嗨,巴纳尔…谢谢指出…这是一个复制错误,我已经更正了。谢谢,我做了类似的事情…我使用了autoexpect并比较了生成的代码!