Try adding a match for any line after the matches for your relevant
stuff and continue with expect, i.e.
[ 'your_match' => sub { ... } ],
[ '\n' => sub { exp_continue } ],
That way expect() keeps gobbling up any lines it cannot match.
Hope this helps,
Roland
Ivan the Perl wrote:
> I'm using Expect to configure an ill-behaved network device and having
> problems.
> The device has the characteristic that is sends out 'lines' consisting of
> '\n', or '\r\n' and nothing else.
> This causes problems as '^$' will not match the later and will match
> 'nothing' which does not consume any of the input that's been accumulated.
> I used clear_accum when before() or after() matched the patterns in
> question, but that does not seem to cause the accumulator to acquire more
> content (and the expect times out). I also tried something crude like
> set_accum(' ') when either of the undesirable patterns matched, just so
> something ended up in the accumulator. (I was hoping to 'prime the pump'
> and force another read for more input from the device.) The device timed
> out. I even tried matching '^.*?\r(.*)$' and '^(?:.*?\r)?(.*)$' combined
> with set_accum($1), but all that does is turn '\r\n' into '\n' which then
> fails as I can't use '^$' to match.
>
> Has anyone run into this 'empty line' problem before?
> How did you work around it?
|