Can IPC :: System :: simple STDERR capture?

I would like to call a script from my Perl code and grab its STDERR and STDOUT together.

I usually use capturefrom IPC::System::Simple, but ti does not seem to allow STDERR capture.

+3
source share
2 answers

On a POSIX system, you can do the following. On Windows, this will work in cygwin .

my @lines = capture("some command 2>&1");

However, if you want to distinguish STDERR strings from STDOUT strings, you might need to use IPC :: Open3 or the incorrectly named IPC :: Open3 :: Util .

+2
source

STDERR ( 2) STDOUT ( 1) 2>&1.

perlop qx//:

, ( , ), . STDERR STDOUT :

$output = `cmd 2 > & 1`;

+3

Source: https://habr.com/ru/post/1773378/


All Articles