在期望可以获取特定文本的同时发送命令 [英] Send command while expect can get specific text
本文介绍了在期望可以获取特定文本的同时发送命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在使用Expect时遇到一个问题. 我需要列出一些信息. 但是程序列出了10个项目,然后显示(更多...)并等待一个键 所以:
I Have one problem when i am using expect. I need to list some information. But the program list 10 items and then shows (More...) and waits a key So:
expect "More..."
send "\n"
但是该程序显示了更多的10行,然后再次执行,我可以跟踪需要执行多少次,但是列表变化很大.
But the program shows more 10 lines and does it again, i can track how many times i need to do that, but the list changes a lot.
有没有办法做类似的事情:
Is there a way to do something like:
while expect "More..." do
send "\n"
done
我知道期望值会等待一个字符串,是否存在某种命中"命令?
I know the expect waits for a string, is there some kind of "hit" command?
谢谢
推荐答案
您要exp_continue
和expect
的块形式:
expect {
"More..." {
send "\n"
exp_continue
}
"something else to expect for"
}
这篇关于在期望可以获取特定文本的同时发送命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文