Tcl/Expect 文件无明显原因空闲?

发布于 2024-10-03 07:39:10 字数 409 浏览 3 评论 0原文

在学习了一些教程后,我尝试在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

胡渣熟男 2024-10-10 07:39:10

您在 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

心欲静而疯不止 2024-10-10 07:39:10

“……期待……空转……”总是预示着一个充满错误转折的叙述,最终发现,哎呀,有人认为匹配的“期待$模式”之一,但实际上不< /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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文