I'm looking for some sort of functionality to "peek" at stdout without removing it from expect's buffer so it can be read in by another expect command. Alternatively, is there a way to put it back in the buffer after reading it?
EDIT: Was asked for some code, it's basically a shell prompt similar to:
(prompt) bad_command_that_was_sent
error message
(prompt) successful_command_that_was_sent
(prompt) other_successful_command
long barf of data that has
very little consistency
and almost no way to tell when it\'s
about to end as the prompt just shows
up again suddenly but I really want to save
it and parse it.
(prompt)
And right now i'm looking at it like this:
expect {
-re "Error message regex" {error handling part}
-re "Prompt regex" {anything I need to do with successes}
}
I'm currently using a workaround where I send an extra newline (send "command\r\r"
) which gets me 2 prompts to detect, but this isn't ideal, and is/has been actually causing some bugs.