Lefsler
Lefsler

Reputation: 1768

Send command while expect can get specific text

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

Upvotes: 1

Views: 435

Answers (1)

glenn jackman
glenn jackman

Reputation: 246837

You want exp_continue and the block form of expect:

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

Upvotes: 1

Related Questions