Solved

500 Internal Server Error and Premature End of Script Headers

Posted on 2004-08-20
5
189 Views
Last Modified: 2013-12-25
Hi,

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 68.41.173.155] Premature end of script headers: /www/o/p/optimizexp.net/cgi-bin/autoresponder/ar.cgi

The source is at:
http://www.keinetworks.org/arsource

Thanks a lot!
0
Comment
Question by:ksg455
  • 2
  • 2
5 Comments
 
LVL 48

Expert Comment

by:hernst42
ID: 11864558
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:
#!/usr/bin/perl^M$
The file has the wrong format it should print
#!/usr/bin/perl$

If you have no shell-access make sure your program that uploads the ar.cgi converts the CL/LF TO LF only
0
 

Author Comment

by:ksg455
ID: 11865274
[root@smeserver autoresponder]# cat -e ar.cgi | head -1
#!/usr/bin/perl^M$
[root@smeserver autoresponder]# cat -e config.cgi | head -1
#!/usr/bin/perl^M$
[root@smeserver autoresponder]# cat -e activate.cgi | head -1
#!/usr/bin/perl^M$
0
 
LVL 48

Accepted Solution

by:
hernst42 earned 230 total points
ID: 11865428
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
0
 
LVL 5

Expert Comment

by:Peewee
ID: 11868408
ksg455,
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.  

Peewee
0
 

Author Comment

by:ksg455
ID: 11869287
hernst42, that did the trick. It works now. Thanks!!
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

In this tutorial I will show you how to provide a dynamic RTF document on your website generated with data from your database. For this tutorial you will need Microsoft Word or WordPad, WhizBase and Microsoft Access. In this tutorial I will show …
Active Directory replication delay is the cause to many problems.  Here is a super easy script to force Active Directory replication to all sites with by using an elevated PowerShell command prompt, and a tool to verify your changes.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now