> Am testing out a new web server running SunOS5.8 " and I 
> can't get any of my cgi scripts to run.  I get this error message:
> "Premature end of script headers"
>
> the cgi scripts worked perfectly on the old server which was running
Digital  UNIX.

In general this means your script died before returning any data.  There's
usually some more information in your web server's error log.  Possible
causes for this kind of problem include:

1) The web server is running as user "nobody" or some other userID with no
special privileges, so your Perl cgi scripts need to have their permissions
set to allow world read/execute access.  Fix:  go to the directory with your
script and type chmod o+rx script.cgi, where "script.cgi" is the name of the
cgi script you're trying to run.

2) The Perl executable isn't where you thought it was (for example, your
script starts with the line "#!/usr/bin/perl" and should be
"#!/usr/local/bin/perl" or vice versa).  Fix:  use "which perl" to find out
where the Perl executable is, and put the correct path on the first line of
your script.

3) Your old web server automatically supplied the proper CGI headers (so
your script doesn't generate them) but the new server requires your scripts
to generate its own CGI headers.  Fix:  Make sure your script includes code
such as the following

#!/usr/bin/perl

use CGI;

$cgi = new CGI;

print $cgi->header;  # print this before printing *anything* else!

4)  Your script is calling executables that don't exist on the new server.
Fix:  don't do that!  :)

A good debugging trick is to add the following lines to the top of all your
scripts:

#/usr/bin/perl
print "Content-type: text/plain\n\n";   # output raw text for debugging

use CGI;
use CGI::Carp qw(fatalsToBrowser);

The above lines will force your script to always return an error message if
it crashes, and will also force your script to print everything as plain
text, which can help in debugging header problems.  If you're not having
header problems, you can print the standard CGI header, as in #3 above
instead, and you'll see a real web page, possibly with Carp's error messages
if any.

Hope this helps.

Mark Nutter
Manager, Internet Applications Development
Marconi
[EMAIL PROTECTED]
It's not necessarily an advantage to have better brakes than the guy behind
you.

Reply via email to