Redirecting STDERR to STDOUT (on NT) 
Author Message
 Redirecting STDERR to STDOUT (on NT)

Hello everyone,

how can I redirect STDERR to STDOUT so die "string" would work
correctly?

Is it possible at all?

I don't want to use my function.

TIA
Paulius



Wed, 18 Jun 1902 08:00:00 GMT  
 Redirecting STDERR to STDOUT (on NT)
Paulius writes ..

Quote:
>how can I redirect STDERR to STDOUT so die "string" would work
>correctly?

I'll ignore the "so die [...] would work correctly" and just answer the
first part of your question (die works correctly on all the NT systems
I've used it on without any intervention)

redirecting STDERR to STDOUT is done on NT the same as it is done on
UNIX .. see the documentation on open() in the perlfunc documentation
for examples and explanations

--



Wed, 18 Jun 1902 08:00:00 GMT  
 Redirecting STDERR to STDOUT (on NT)

Quote:
>how can I redirect STDERR to STDOUT so die "string" would work
>correctly?

try using eval
-hoz


Wed, 18 Jun 1902 08:00:00 GMT  
 Redirecting STDERR to STDOUT (on NT)


Quote:
> >how can I redirect STDERR to STDOUT so die "string" would work
> >correctly?

> try using eval

Ah, that's the ticket!  'eval'.  Hmmm, nothing happened.

What on earth are you talking about?

--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/



Wed, 18 Jun 1902 08:00:00 GMT  
 Redirecting STDERR to STDOUT (on NT)

Quote:

>how can I redirect STDERR to STDOUT so die "string" would work
>correctly?

>Is it possible at all?

Two easy ways:

 a) redirecting STDERR:

        open STDERR, '>&STDOUT';

 b) setting a $SIG{__DIE__} and/or $SIG{__WARN__} handler, which may
format the output in whatever way it likes. Do this in a BEGIN block if
you want to see compile time errors in the same way.

    #! perl -w
    BEGIN {

        $SIG{__DIE__} = sub {

    }
    print $x/$y;
    print "Heh.\n"; # you won't see this.

I'm not quite happy about that { die "\n" } hack, though (die
"silently").

--
        Bart.



Wed, 18 Jun 1902 08:00:00 GMT  
 Redirecting STDERR to STDOUT (on NT)


....

Quote:
>     #! perl -w
>     BEGIN {

>         $SIG{__DIE__} = sub {

>     }
>     print $x/$y;
>     print "Heh.\n"; # you won't see this.

> I'm not quite happy about that { die "\n" } hack, though (die
> "silently").

How about this clever replacement for your 'die "\n"':

    exit;

--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/



Wed, 18 Jun 1902 08:00:00 GMT  
 Redirecting STDERR to STDOUT (on NT)

Quote:

>How about this clever replacement for your 'die "\n"':

>    exit;

Try this in an "eval". You program will STILL quit.

    #! perl -w
    BEGIN {

        $SIG{__DIE__} = sub {

    }
    eval {
         print $x/$y;
         print "Heh.\n";
    };
    print "Resuming\n";
-->
  Oops: Name "main::x" used only once: possible typo at test.pl line 8.
  Oops: Name "main::y" used only once: possible typo at test.pl line 8.
  Oops: Use of uninitialized value at test.pl line 8.
  Oops: Use of uninitialized value at test.pl line 8.
  Argh!: Illegal division by zero at test.pl line 8.
  I'm dead.

No "Resuming".

That's why I use "die" inside the SIG handler too. I assume there must
be a "resume dying" syntax, I though I had seen it once, but I can't
find it any more. A simeple "die;" is not it.

--
        Bart.



Wed, 18 Jun 1902 08:00:00 GMT  
 Redirecting STDERR to STDOUT (on NT)

Quote:



>> >how can I redirect STDERR to STDOUT so die "string" would work
>> >correctly?

>> try using eval

>Ah, that's the ticket!  'eval'.  Hmmm, nothing happened.

>What on earth are you talking about?

I am talking about using an eval on the EXPR then catching the error



Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 8 post ] 

 Relevant Pages 

1. Help redirect STDOUT, STDERR under NT !!!

2. HELP - with redirect of STDERR and STDOUT

3. redirect STDERR to STDOUT ?????

4. redirecting stderr and stdout

5. writing to terminal even with STDOUT and STDERR redirected

6. assigning STDERR whild redirecting STDOUT to a file

7. Problem with redirecting STDOUT and STDERR

8. How to redirect STDOUT,STDERR and keep the message order

9. Redirect stderr to stdout w/ Perl under Unix?

10. HELP - with redirect of STDERR and STDOUT

11. need to redirect STDOUT and STDERR

12. Redirecting stdout/stderr from a call to system()

 

 
Powered by phpBB® Forum Software