yosefm has asked for the wisdom of the Perl Monks concerning the following question:

Hi all.

I'm working on a CGI script that runs through apache server. So far there was nothing wrong with it. But when I tried calling it with parameters, It ignored error messages. Unless I told it to die.

When I did this:

print STDERR "$mtype $mode";

nothing showed up in my error log.

But when I said: print STDERR "I'm dying " and die "horribly";

I did get in my err log - "I'm dying horribly".

What's up with that?

Replies are listed 'Best First'.
Re: STDERR ignored?
by gellyfish (Monsignor) on Jun 21, 2003 at 09:26 UTC

    Well it works for me. When I run:

    #!/usr/bin/perl -w use strict; use CGI qw(:standard); print STDERR "TEST"; print header(),start_html(),"foo";
    I get 'TEST' in my error log as I expect. It is difficult to know what is going on for you without more information but I would suspect that you are running the program under mod_perl although I am not sure how the die() would work under that circumstance.

    /J\
    
      I'm not running under mod_perl. This is just a regular CGI scripts. The wierd thing is that this behaveiour only happens when I give my script parameters (/.../addItem.cgi?media_type=1).

        I think you had better show us the smallest bit of code that you have that exhibits this behaviour as my test program still prints to the error log when I add parameters.

        /J\
        
Re: STDERR ignored?
by fglock (Vicar) on Jun 21, 2003 at 18:48 UTC

    I might be wrong with this, but just in case - try adding a newline at the end:

    print STDERR "$mtype $mode\n";
      Thanks a lot! That's it!

      (How stupid of me...)