是否可以从Win32 :: Jobs管道stdout?

时间:2017-12-19 20:30:42

标签: perl

无论如何将它重定向到一个自动刷新的管道(打开$ 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");       
}

0 个答案:

没有答案
相关问题