Trying to capture an error

Eric Thelin eric at
Mon Sep 11 13:28:38 CDT 2000

On Sat, 9 Sep 2000, Webmaster wrote:

> 1.  The bug is intermittant. It happens only about 10-20 percent of the time
> when use a certain package.  I simply get the dreaded "Premature End of
> Script Headers".

Are you running mod_perl?  I have seen it die randomly.  I am sure this
is partly due to something I am doing wrong but I was able to better
debug my scripts using cgi first.

You may try running the script offline where you can track it better.
A cgi script is just like any other script it just expects to get its
data in one of two ways, as a list of variables in the QUERY_VARS
environmental variable or from stdin.  In the past I have written a
small script that just reports all environmental variables and input
data and stores it in a file then I wrote a simple shell script that
will resend that data to my perl script.  This allows me to run it
offline and see exactly what it is doing and gives me the option of
using the perl debugger.

I have also found it to be very useful to add extra debugging prints to
STDERR which go directly into the error_log to find where the problem is.

Since the bug is intermittent you will probably have to run it a few
times to get it to fail but you should be able to control the test
better this way.  Because you will have to run it many times telneting
into the port will not be very fun.  But a better option would be to use
something like 'curl' (look for it in freshmeat if you want it) which
will request a page and output exacly what the webserver returns wich
can include the headers as well.

Good luck.  There is nothing worse that an intermittent bug.


Eric Thelin                                          erict at
  Where Arizona Does Tech Business
               Voice: 480-377-6743   Fax: 480-377-6755

More information about the Phoenix-pm mailing list