I would like to use expect to parse through the contents of a file, something like this:
spawn cat log/mylog.txt
expect {
-re "some_expr" { ...do something... }
default { ...do something else... }
Note that I am simply reading a file, so there is nothing really interactive going on. Even so, this works most of the time, but sometimes I think that expect gets ahead of itself and tries to read the file contents before they are ready, and I get failed tests.
Is there some convenient way to use the spawn/expect sequence for reading through a file? Is there any easy way to force expect to wait until the spawn is completed?
Spawn/expect are designed for interactive use. Since I am mostly non-interactive, is there a better way to do this than the approach I am taking?
Thanks in advance.
spawn cat log/mylog.txt
expect {
-re "some_expr" { ...do something... }
default { ...do something else... }
Note that I am simply reading a file, so there is nothing really interactive going on. Even so, this works most of the time, but sometimes I think that expect gets ahead of itself and tries to read the file contents before they are ready, and I get failed tests.
Is there some convenient way to use the spawn/expect sequence for reading through a file? Is there any easy way to force expect to wait until the spawn is completed?
Spawn/expect are designed for interactive use. Since I am mostly non-interactive, is there a better way to do this than the approach I am taking?
Thanks in advance.