Using PHP's proc_open()
, I can start a process, read from STDOUT
and STDERR
(separately) an arbitrary number of bytes at a time using fread()
while the process is running, detect when the process is done using feof()
on the STDOUT
and STDERR
pipes, and then use proc_close()
to get the exit code of the process. I've done all of this in PHP. It works well, and gives me a lot of control.
Is there a way to do all of these things in Perl? To summarize, I need to be able to do the following:
- start an external process
- read
STDOUT
andSTDERR
separately - read
STDOUT
andSTDERR
an arbitrary number of bytes at a time while the process is running (i.e. without having to wait for the process to finish) - detect when the process is finished
- get the exit code of the process
Thanks in advance for your answers.