redirection from STDERR 
Author Message
 redirection from STDERR

Hello.

I wish to call an executable program xyz from within a perl script bubba.pl.
The program xyz redirects STDERR into STDOUT.  I wish to seperate the STDERR
messages from STDOUT from within my perl script.  Normally at the shell prompt
I could do the following:

brtphe33-132> (xyz > file.stdout) >& file.stderr

I have tried some of the standard techniques for talking to oneself using the
open with "|-" and having the parent talk with the child, but when I execute
xyz from my perl script, I do not control the output of STDERR and it appears
at the screen from my perl script.

If anyone could give any insight on my problem, I would really appreciate it.
Thanks.

Teebu
--

NORTEL (RTP Lab)     XPM Diagnostic Development, Dept. 3X41
35 Davis Dr.         Voice: (919) 991-2602    ESN: 294-2602
RTP, NC  27709       FAX:   (919) 991-4126    ESN: 294-4126



Fri, 14 Jan 2000 03:00:00 GMT  
 redirection from STDERR

[ Posted and mailed. ]

Quote:

> I wish to call an executable program xyz from within a perl script
> bubba.pl.  The program xyz redirects STDERR into STDOUT.  I wish to
> seperate the STDERR messages from STDOUT from within my perl script.
> Normally at the shell prompt I could do the following:
> brtphe33-132> (xyz > file.stdout) >& file.stderr

        system 'xyz > file.stdout 2> file.stderr';

Perl uses sh syntax, not csh syntax, for redirects.  Alternately, if you
need to be able to grab them both as Perl file handles, you can do
something along the lines of:

        use FileHandle;
        use IPC::Open3;

        $write = new FileHandle;
        $read = new FileHandle;
        $errors = new FileHandle;
        open3 ($write, $read, $errors, 'xyz');

and then read the errors from $errors and stdout from $read.

--
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker





Fri, 14 Jan 2000 03:00:00 GMT  
 redirection from STDERR

: Hello.

: I wish to call an executable program xyz from within a perl script bubba.pl.
: The program xyz redirects STDERR into STDOUT.  I wish to seperate the STDERR
              ^^^^^^^^^^^^^

So, external to xyz, all output comes out on STDOUT?

: messages from STDOUT from within my perl script.  

It is too late, if they were merged internal to xyz.

: Normally at the shell prompt
: I could do the following:

: brtphe33-132> (xyz > file.stdout) >& file.stderr

[ isn't csh awful in its handling of file descripters?  (rhetorical question) ]

Ahhh. If that works, then xyz does NOT "redirect STDERR into STDOUT"
as you said above.

So, now I'm confused as to what xyz does.

Does xyz _itself_ redirect STDERR to STDOUT, or not?

If not, then you probably want to have a look at this Frequently
Asked Question:  "How can I capture STDERR from an external command?"

If so, then it is too late to separate them, unless there is something
in the data that you can key on to know whether it was intended for
STDERR or STDOUT.

: I have tried some of the standard techniques for talking to oneself using the
: open with "|-" and having the parent talk with the child, but when I execute
: xyz from my perl script, I do not control the output of STDERR and it appears
: at the screen from my perl script.

: If anyone could give any insight on my problem, I would really appreciate it.
: Thanks.

--
    Tad McClellan                          SGML Consulting
    Tag And Document Consulting            Perl programming



Fri, 14 Jan 2000 03:00:00 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. redirection of STDERR

2. system and STDERR redirection ???

3. STDERR Redirection within script

4. one-line stderr, stdout redirection

5. STDERR Redirection question

6. STDOUT/STDERR Redirection (Win32)

7. STDERR redirection

8. Stdout/Stderr redirection (Win32)

9. Probs w/ redirection and capture of STDERR/STDOUT

10. STDERR redirection X 2 ??

11. STDERR redirection and `command`

12. Bourne shell stderr redirection

 

 
Powered by phpBB® Forum Software