Send command while expect can get specific text

2019-07-25 18:01发布

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

标签: expect
1条回答
Summer. ? 凉城
2楼-- · 2019-07-25 18:17

You want exp_continue and the block form of expect:

expect {
  "More..." {
    send "\n"
    exp_continue
  }
  "something else to expect for"
}
查看更多
登录 后发表回答