I have figured out how to do it!!

        open CVSDIFF, "pipe (define/user sys\$error sys\$output ; cvs diff
--brief -l -r prdsr$LAST_PRD_ROLL_DATE @wildcards_subset
) |";   

Using pipe that way did the trick...

Thank you very much for all the tips.

Patrick


-----Original Message-----
From: Craig Berry [mailto:[EMAIL PROTECTED]]
Sent: Monday, January 13, 2003 2:22 PM
To: Li, Patrick
Cc: '[EMAIL PROTECTED]'
Subject: RE: redirecting STDERR to STDOUT inside a program


 
On Monday, January 13, 2003, at 01:20PM, Li, Patrick <[EMAIL PROTECTED]>
wrote:

>I'm still struggling with finding a way to redirect STDERR to STDOUT...
>
>I have created a perl script called testscript which does this:
>print "1. this goes to standard out\n";
>warn "1. this goes to standard err\n";
>warn "2. this goes to standard err\n";
>
>and then i defined sys$error to goto sys$output...and i tried running it
>here...
>
>$ define/user sys$error sys$output
>$ perl testscript >test.txt
>$ type test.txt
>1. this goes to standard err
>2. this goes to standard err
>
>
>Why is it that the line that's supposed to goto stdout didn't appear in
>test.txt?

It did.  It just appeared in a different version of it.  Try

$ type test.txt;1
$ type test.txt;2

Whether that's a bug or feature of DCL (the shell) I can't say for sure.

As others have pointed out, Perl can do what you want just like it does on
Unix:

$ perl testscript.pl 2>&1 > test.txt

However, I thought your original problem had to do with cvs writing to a
pipe that is read by Perl.  You might try:

$ pipe cvs [cvs switches and args] 2> sys$output > foo.txt

and see what the resulting file looks like.  I have no idea whether that
will work.  To test it properly, you'll obviously need to give it a cvs
command that produces both stderr and stdout output; connecting to a
nonexistent server and using verbose mode would probably do the trick.

Reply via email to