Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

Re: Get live output of exec

by kennethk (Abbot)
on Mar 04, 2014 at 01:00 UTC ( #1076822=note: print w/replies, xml ) Need Help??

in reply to Get live output of exec

As LanX wisely says, read perlipc. Every topic below is discussed, in more detail and with examples.
The parent script then generates signals to the running child exec
Communicating via STDIN to the child would probably be easier than signals. Like in IPC::Open2.
how can I get a stdout line from the child immediatly in the parent script?
If you are piping (which you need to do if you are running via exec), you need to turn on autoflush. See IO::Handle or $| and select.
And how do I tell in the parent script when the child has finished?
kill can test if the executable is still running (kill(0, $pid)). wait or waitpid can be used to reap the child. IO::Select or eof can be used to check if the child has something to say.

#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1076822]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (4)
As of 2018-01-23 07:13 GMT
Find Nodes?
    Voting Booth?
    How did you see in the new year?

    Results (241 votes). Check out past polls.