Directing stderr when opening a pipe? 
Author Message
 Directing stderr when opening a pipe?

I want to read both stdout and stderr of a pipe, a la
        open(PIPE, "command args |");
Unfortunately, I can't find anything in any documentation, nor have my
own experiments turned up any way of accomplishing this.

Have I missed something, or is this simply not possible?  What's the
best alternative?  I guess I can dump the output into a temporary file
and read it from there.

Thanks for any help.
--

Environmental Molecular Sciences Laboratory | Phone: 509 375 4387
Pacific Northwest Laboratory, MSIN K1-90    | Fax:   509 375 6631
P.O.B 999, Richland, WA  99352-0999         |



Tue, 25 Nov 1997 03:00:00 GMT  
 Directing stderr when opening a pipe?

David> I want to read both stdout and stderr of a pipe, a la
David>       open(PIPE, "command args |");
David> Unfortunately, I can't find anything in any documentation, nor have my
David> own experiments turned up any way of accomplishing this.

Just use bourne shell syntax:

        open PIPE, "command args 2>&1 |";

Simple if you know the One True Shell (/bin/sh).  Which everyone should
learn, even if they *are* using Perl.

print "Just another Perl hacker," # but not what the media calls "hacker!" :-)

--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying

Web: <A HREF="http://www.teleport.com/~merlyn/">My Home Page!</A>



Wed, 26 Nov 1997 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Directing stderr and stdout to a pipe

2. How do you direct STDERR into a pipe?

3. Piping in stderr when creating a pipe with the open call

4. "open" pipe with stderr

5. open a piped command including stderr

6. Changing STDERR for an open pipe statement (How ?)

7. Re-directing stderr

8. PERLFUNC: open - open a file, pipe, or descriptor

9. PERLFUNC: open - open a file, pipe, or descriptor

10. Perl's open() pukes when trying to open a read-type pipe

11. Piping STDERR

12. reading stdout/stderr using pipes

 

 
Powered by phpBB® Forum Software