Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Get live output of exec

by kennethk (Monsignor)
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.


Comment on Re: Get live output of exec
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1076822]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2014-07-25 12:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (171 votes), past polls