Rerouting STDERR to STDOUT - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Rerouting STDERR to STDOUT

WeirdofreakWeirdofreak Posts: 439Member
I have a CGI which was working fine the day before yesterday, and is now not working at all. I'm getting the message 'Script produced no output' when I run, which means it got a syntax error and sent the message to STDERR, the logs of which I don't have access to. Or if I do, I can't find them. I'm sure if I could work out what the probem is I could get a solution, but I need it to send the message directly to the browser via STDOUT for that to happen. So how would I reroute it? I'm pretty sure it has something to do with pipes, but I don't understand them at all.

Comments

  • JonathanJonathan Posts: 2,914Member
    : I have a CGI which was working fine the day before yesterday, and is now not working at all. I'm getting the message 'Script produced no output' when I run, which means it got a syntax error and sent the message to STDERR, the logs of which I don't have access to. Or if I do, I can't find them. I'm sure if I could work out what the probem is I could get a solution, but I need it to send the message directly to the browser via STDOUT for that to happen. So how would I reroute it? I'm pretty sure it has something to do with pipes, but I don't understand them at all.
    :
    Here's a couple of ideas for you:-

    1) Try popping this near the top of your script to send errors to the browser window:-
    use CGI::Carp qw(fatalsToBrowser carpout);

    2) Try doing something like:-
    [code]close STDERR;
    open STDERR, "> logfile.txt";[/code]
    And log errors to that file. Again, do it near the top of your script.

    Re-routing - leave that with me to think about. Something like:-

    *STDERR = *STDOUT;

    May work for you, can't be sure.

    Hope this helps,

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • JonathanJonathan Posts: 2,914Member
    Hi,

    What I said only applies for runtime erorrs. To find compile-time ones you can usually do:-

    perl -c thescript.pl

    To run a syntax check.

    Jonathan

    ###
    for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
    (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
    /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");

  • WeirdofreakWeirdofreak Posts: 439Member
    Thanks for the help. I did I syntax check and it was fine, so I tried the script again, and it also worked fine. I did nothing to break it, and didn't have to do anything except wait to fix it. Strange, but at least it was simple. :)
Sign In or Register to comment.