Hi
Yes, you can read the object in non-blocking mode until you know it is done or you find some pattern in the output..
A "tail -f" will normally not return a prompt anymore, unless you kill the task; also it will only produce output if lines are added to the file being tail-ed. So you won't be able to use the cmd() command on the "tail -f" or it will timeout not seeing a prompt and the problem with using waitfor() or readwait() is that they will also timeout if no output is seen for the duration of the timeout. You could use readwait() in non-blocking mode but then why not just use read() in non-blocking mode.
I'm not entirely sure how you envisage the "tail -f" will come to an end.
What I would suggest is something like this:
$obj->print("tail -f <file>");
while (1) {
Time::HiRes::sleep(0.1); # sleep a bit at every cycle
$output = $obj->read(Blocking => 0);
if (length $output) {
<do something with output>;
if (<we are done condition, based on output>) {
$obj->put("\cC"); #Send CTRL-C to kill tail ?
last; # Come out of while loop
}
}
}
# and to lock on the next prompt..
$obj->waitfor($obj->prompt);
Hope this helps
Best regards
Ludovico Stevens
On Thu Nov 13 13:12:51 2014, chris.ivey@alcatel-lucent.com wrote:
Show quoted text> Is there a methodology which will allow for the output of "tail -f" to
> be brought back to the user in real time? I'm envisioning something
> like:
>
>
> 1.) Start process that creates log via "cmd"
>
> 2.) Issue "tail -f" on log via "cmd"
>
> 3.) Issue "readwait" to read output
>
> 4.) Issue "waitfor" to know when it's done
>
> Thoughts?
>
> Thanks!!
>
> Chris Ivey
> Integration Professional - Accredited
> Software Field Integration
> Customer Engineering - Americas
> Alcatel-Lucent