Forum Moderators: coopster & phranque

Message Too Old, No Replies

Debugging a CGI script

         

runner

9:55 pm on Mar 11, 2008 (gmt 0)

10+ Year Member



All my cgi scripts stopped working at the same time after working for years. Since I have a shared hosting account, I can't get to the actual error message that perl is throwing. The apache logs just contain the generic "premature end of script headers" msg. I don't have shell access to run the script by hand to see the error output.

A while back I saw a perl module or a code snippet that would trap the error and send the output to the web browser before gracefully closing. Now I can't find it anywhere. Been googling for quite a while with no luck.

Does anybody know a way to do this? I've asked the hosting company if they have a sysadmin that can manually run the cgi to get to the error msg but I don't know how long it will take them go get around to it.

runner

9:59 pm on Mar 11, 2008 (gmt 0)

10+ Year Member



Oh... I find it ten seconds after I post this message:

use CGI::Carp qw(fatalsToBrowser);

perl_diver

10:37 pm on Mar 11, 2008 (gmt 0)

10+ Year Member



that will display most errors but not all, did it help you resolve the problem?

chorny

10:08 pm on May 8, 2008 (gmt 0)

10+ Year Member



BEGIN {
use CGI::Carp qw(fatalsToBrowser);
}
at top of your program (after use strict;use warnings;)

or

BEGIN {
open STDERR,'>>','errors.log';
}

[edited by: phranque at 2:56 am (utc) on May 9, 2008]
[edit reason] disabled smileys ;) [/edit]