• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 230
  • Last Modified:

500 Internal Server Error and Premature End of Script Headers


This is driving me crazy. I downloaded a CGI script and it absolutely refuses to run. I'm a CGI "newbie", but I have done the following things:

1. CHMOD'd everything right (Directory & CGIs 755, pm 644)
2. Added the Header and "use strict;" (those weren't there before)
3. Checked the logs.

Yet it STILL gives a 500 Internet Server Error.

The log reads:
[Fri Aug 20 14:21:14 2004] [error] [client] Premature end of script headers: /www/o/p/optimizexp.net/cgi-bin/autoresponder/ar.cgi

The source is at:

Thanks a lot!
  • 2
  • 2
1 Solution
Have you checked that the ar.cgi has the correct format on the unix-platform. That file may not be saved in DOS-mode with CR/LF

If you have shell-access to that server do a
cat -e ar.cgi | head -1
If you get something like the following:
The file has the wrong format it should print

If you have no shell-access make sure your program that uploads the ar.cgi converts the CL/LF TO LF only
ksg455Author Commented:
[root@smeserver autoresponder]# cat -e ar.cgi | head -1
[root@smeserver autoresponder]# cat -e config.cgi | head -1
[root@smeserver autoresponder]# cat -e activate.cgi | head -1
so your scripts are in dos-format and the interpreter can't be found. you have to recode them. Then the scripts should work. To recode use

dos2unix ar.cgi
dos2unix config.cgi

if dos2unix is not installed try the following:
recode ibmpc..lat1 ar.cgi
recode ibmpc..lat1 config.cgi

maybe you also need to remove some of the prints you added in various files to get it work
since you've added the use strict, you should also run a perl -c on the unix command line to check for any addittional syntax errors.  

ksg455Author Commented:
hernst42, that did the trick. It works now. Thanks!!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now