in reply to Re: Capturing STDOUT and STDERR of system command, with pure perl?
in thread Capturing STDOUT and STDERR of system command, with pure perl?
Simplified to this...
# To get the numerical result (in most cases, the error code) of the command use the $res variable...
my $thecmd = "dir";
my $res = system("$thecmd . " 1>C:/output 2>1");
print $res;
# To get the string output result of the command, just look at the file in C:/output...
open(SYS_OUT, "C:/output") or die "Could not open the output";
my $output = join "", <SYS_OUT>;
close SYS_OUT;
print $output;