无论如何将它重定向到一个自动刷新的管道(打开$ pipe,' - |',$ args-> {command})?
local $| = 1;
my $pipe = undef;
my $pid = $job->spawn("cmd", "cmd /C \"$args->{command}\"",
$args->{opts} ||
{
cwd=>"C:\\Test_Dir",
stdin=>'NUL ',
stdout=>(exists $args->{show_output} && $args->{show_output} ? $pipe : 'NUL ')
}
if(defined $pipe){
print("STDOUT:\n==================================\n");
while (defined( my $line = <$pipe> )) {
chomp($line);
print(">> $line\n");
}
print("\n==================================\n");
}