I want to call a EXE file in Perl which performs some action
I tried calling the exe file via backtick
and system
but in both the cases i get only the return value
The exe file prints some text on to the console. Is it possible to capture that as well?
I looked into this variable ${^CHILD_ERROR_NATIVE}
but I get only the return value and not text
I am using Perl 5.14
Thanks in advance
The application might not print its output to STDOUT
but STDERR
instead, which isn't captured by the backtick operator. To capture both, you could use the following:
my $binary = 'foo.exe';
my $output = `$binary 2>&1`;
For a more fine-tuned capturing, you might want to resort to IPC::Open3
with which you can "control" all of a process' streams (IN
, OUT
and ERR
).