Start and control a process and capture all its output with Perl (on Windows)?

I would like to be able to do the following (and it should work on Windows):

  • Start external command / process
  • Grab all of its stdout and stderr (if any)
  • Do it asynchronously (Script doesn't have to wait for the process to complete.)
  • "Monitor": when the process ends, find out its exit code
  • "Monitor": If the process does not terminate (timeout), it can terminate the specified process.
  • I don't need to send anything to this process via stdin

I must say I am totally lost among all the things inIPC::

... Open3

, Run

, Cmd

.. oh my ... adding to Capture::Tiny

, etc. and the caveats mentioned for Win32.

Which modules from the Perl toolbox are recommended above? Strawberry Perl 5.14 and up. Any additional CPAN module is fine.

+3


source to share


1 answer


On Windows, I am using ActiveState ActivePerl.

There is a Win32 interface. Take a look at Win32 :: Process, I think it might satisfy some of your requirements for running processes on Windows.

http://docs.activestate.com/activeperl/5.18/lib/Win32/Process.html

You can take a look at other Win32 interfaces.



Be careful not to run some CPAN module on Windows, especially when multithreading, forks are involved because they were developed on Unix platforms.

PS I would be wondering if MINGW32 would be a Unix-like solution on Windows.

Hope it helps

0


source







All Articles