Send command while expect can get specific text

梦想的初衷 提交于 2019-12-13 20:03:35

问题


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"

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?

Thanks


回答1:


You want exp_continue and the block form of expect:

expect {
  "More..." {
    send "\n"
    exp_continue
  }
  "something else to expect for"
}


来源:https://stackoverflow.com/questions/11797697/send-command-while-expect-can-get-specific-text

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!