in reply to Capturing output from Child processes

I don't know about any Windows weirdness, but have you tried just piping from the command directly?

open(FH, "dir|") or die "Couldn't run dir: $!\n";

Under UNIX, this construct seems to work fine:

#!/usr/bin/perl defined ($pid = open $fh, "-|") or warn $! and last; if ($pid) { # Parent while (<$fh>) { print "OUTPUT: $_"; } } else { # Child exec("/bin/ls"); }

Replies are listed 'Best First'.
Re: Re: Capturing output from Child processes
by Biff (Acolyte) on Aug 06, 2003 at 18:30 UTC
    sgifford,

    Thanks. Yea, open with the command doesn't give me any errors but I have yet to get any output from the child. I tried -| in desperation. After getting my post "duped" I went and searched harder in the archives and found a post that says that |- and -| aren't supported on windows.

    I'm still not sure what open with the -| buys you that open with the command doesn't but onward and well... onward.

    Thanks again,

    Biff