我有一个问题,即 runscript 在 Linux 完成启动后能够捕捉到提示之前退出。我的“证据”是它的退出是,一旦提示可见,可以拉出 minicom 菜单,但我的“发送”从未发出。否则,当 minicom 运行脚本时,它不需要用户输入 ctrl+az 等内容。
为了尝试查看脚本是否超时,我尝试在期望中添加超时:
print "\n\n#####\nExec Linux\n#####\n\n"
send exec -c \"noinitrd console=ttymxc0,115200 root=/dev/nfs<etc.>
expect {
"ubiformat:"
"root@xxx_yyy:" break
"root@xxx.yyy:" break
"root@undefined.yyy:" break
timeout 300 print "\n\n\n#####\n Expect timeout waiting for prompt during Linux boot, not going to do flash.sh\n#####\n\n"
}
这导致我的日志文件包含:
MXC Watchdog # 0 Timer: initial timeoutscript "update.mc" line 111: unknown command "300"
有趣的是,在脚本有效的板上,它始终有效。在那些命令提示符没有被期望捕获的地方,它总是失败。
我在 vim 中打开日志文件并发出 ":set list" 以查看提示符是否完全符合我的预期并且确实如此。
关于期望模式的注释:
"ubiformat:" // trying to reset timeout every time ubiformat is seen, so extra time it takes to format NAND doesn't cause a timeout
"root@<*>:" break // trying to catch one of the possible prompts, either consistently works or fails based on boards tested on
timeout 300 print "..." // trying to print a message if the reason I'm exiting the expect is because of a timeout, but note the syntax error printed in the log.
问题:关于如何调试为什么有时提示没有被期望捕获的任何建议?关于期望中正确的超时语法的任何建议?
接下来,我将在超时内尝试 1h2m30s 语法,我在某处的一个示例中看到了这一点。如果没有“h”、“m”或“s”,可能不允许 > 60。