in reply to Re: Reading only STDERR
in thread Reading only STDERR

Sure, but then the STDOUT of child.pl gets lost. Try adding a line in child.pl:
#!perl for (1..5) { print STDERR "Message $_\n"; print STDOUT "STDOUT $_\n"; }
You'll see that what's printed to STDOUT doesn't get displayed, because it ends up in parent.pl's RDRFH. I want the STDOUT of child.pl to correspond to parent.pl's STDOUT, not to be a pipe.

Replies are listed 'Best First'.
Re^3: Reading only STDERR
by Roy Johnson (Monsignor) on Apr 06, 2005 at 13:57 UTC
    I hadn't discerned from your original post what you wanted done with STDOUT. To have it sent to parent's STDOUT, you do this in parent.pl:
    $pid = open3(\*WTRFH, '>&STDOUT', \*ERRFH, 'perl child.pl');

    Caution: Contents may have been coded under pressure.
      Thank you very much, that's exactly what I needed. I hadn't realized that you were supposed to write the name of the filehandle in a string. I thought it didn't make much sense, but hey, does Perl make any sense at all? Thanks again!
        Filehandles have always been kludgy. They are just bareword strings that, in the right context, get looked up in the symbol table. Directory handles are the same way. This is probably the most unfortunate design feature in Perl.

        Caution: Contents may have been coded under pressure.
Re^3: Reading only STDERR
by rev_1318 (Chaplain) on Apr 06, 2005 at 14:45 UTC
    I want to open a process and read only its STDERR

    So, do you want STDOUT or not? Your first questions states very clearly that you want to read only STDERR. It's very hard to read someones mind to know they do not ask want they want to know.... :-(
    Pleas learn to ask questions in a proper way

    Paul