Tcl/Expect 文件无明显原因空闲?
在学习了一些教程后,我尝试在 Expect/Tcl 中编写代码。我在执行脚本方面取得了一些成功。但我遇到的一个问题是我的脚本在执行下一个 exp_send 命令之前会空闲一段时间。谷歌搜索后,有人建议在 exp_send 之前小睡一会儿,但这似乎没有什么不同。这是我的相关代码:
exp_send "\r"
expect "\ $"
exp_send "\r"
expect "\ $"
exp_send "\r" <---- Idle waiting here!
expect {
"\r" {
exp_continue
}
}
expect eof
我在exp_send语句中发送信息,但我认为它没有任何意义,所以我没有发布它..
I'm trying to write a code in Expect/Tcl after going through a few tutorials. I've got some success in executing my script. But a problem I have is that my script idles for a while before executing the next exp_send command. Googling, brought be to a suggestion of putting in a small sleep, before the exp_send, but that didn't seem to make any different. Here's my relevant code:
exp_send "\r"
expect "\ $"
exp_send "\r"
expect "\ $"
exp_send "\r" <---- Idle waiting here!
expect {
"\r" {
exp_continue
}
}
expect eof
I am sending information in the exp_send statements, but I don't think its of any significance, so I haven't posted it ..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您在 exp_send 中发送的信息是相关的,因为可能是您正在执行的命令导致了空闲
The information that you're sending in the exp_send IS of relevance, since could be that it´s the command that you're executing that's causing the idling
“……期待……空转……”总是预示着一个充满错误转折的叙述,最终发现,哎呀,有人认为匹配的“期待$模式”之一,但实际上不< /em> 匹配,而只是超时。正确的解决方法是匹配编码器认为应该匹配的 $pattern-s。正确的解决方案不涉及调整等待时间。
http://wiki.tcl.tk/3173 有相关提示。
"... Expect ... idling ..." INVARIABLY presages a narrative with lots of false turns that ends up discovering that, oops, one of the "expect $pattern"-s someone thought was matching did not match, and was instead simply timing out. The correct resolution will be to match the $pattern-s the coder thinks should be matched. Correct resolution does NOT involve adjusting wait times.
http://wiki.tcl.tk/3173 has pertinent tips.