From: Blackstone, J. D. <jda...@ci...> - 2002-06-06 18:57:23
|
* My spawned processs doesn't produce any output, and Expect.pm doesn't wait for it to end. [Might need to reword this. Suggestions? See http://use.perl.org/~djberg96/journal/5430/] Spawning a process just starts it up. From then on, any interaction with your process, including waiting for it to end, is up to you. Usually this involves expect()ing output. If there is no output, however, you will need to expect() a special signal sent when the process ends called eof. Use the array-reference syntax for expect to specify waiting for an eof: $exp->expect($t, [qr/Possible error message/ => sub { ... }], ['eof' => sub { ... }]); (Note that unlike other expected patterns, you currently have to specify a subroutine reference to be called when the eof is encountered. This will probably change in a future release. For now, if you don't want to do anything but wait for the program to exit, use ['eof' => sub { }], with nothing in the curly brackets. Expect.pm's handling of eof is based on the original TCL Expect. More information about original Expect's handling of eof can be found in _Exploring Expect_ by Don Libes, p. 98. * There's no way to reliably determine how long to set my timeouts; can't I make it unlimited? Yes. Use a timeout of C<undef>, Perl's undefined value. After writing this, I'm not sure I liked any of the wording. I won't be offended if someone totally rewrites it. :) |