Forum Moderators: coopster & phranque

Message Too Old, No Replies

Premature end of script headers

         

rizwan65

9:39 pm on Apr 30, 2005 (gmt 0)

10+ Year Member



Hi everybody,
I am running Fedora Core 1 with Apache version 2.0.50 and perl v5.8.3

I am trying to run a test cgi script but getting an error:

Premature end of script headers

When I try to run in shell it runs perfectly
I have checked out the permissions but could not get way out.

The scripts contents are as under:

#!/usr/bin/perl
print "Content-type: text/html\n\n";
print "This is a URL test";

Any Suggestions will be appriciated
Regards
Rizsh

wruppert

1:48 pm on May 1, 2005 (gmt 0)

10+ Year Member



Don't know anything about Apache 2, but it worked fine on FreeBSD/Apache 1.3.

I'm not sure what "could not get way out" meant when you checked permissions. However if permissions are wrong you would get 403 Forbidden and if perl was not found you would get 500 Internal Error.

Perhaps Apache 2 is pickier about the output actually being valid HTML? Your example is text/plain, not text/html.

rainborick

11:16 pm on May 1, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



This error is usually caused by one of three things:

(1) The script file was created by a Windows program like Notepad and didn't get uploaded in Unix/ASCII format. Some FTP programs will translate Windows/DOS text files into Unix/ASCII on the fly with a proper setting. Otherwise you'll need a text editor that can save the files in the proper format on your computer.

(2) The script file's permissions were set improperly. Use the CHGMOD command in your FTP program to set the permissions on the script file to 755, or set it to allow Owner RWX permissions, Group RX permissions, and Other RX permission (where R = Read, W = Write, and X = Execute).

(3) There is a syntax error in the script. Often caused when a user customizes a public script for his site. All it takes is a stray keystroke, or an unescaped "@" to stop execution before it starts.

Good luck!

rocknbil

3:50 pm on May 2, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I have had problems with PC format files (NotePad) on some servers. Almost all Linux servers have pico - SSH/telenet to your server and try this:

cd /directory/of/test.pl
pico test.pl

You are now in the pico editor. press ctrl-o, type in the file name, and overwrite your test file. You won't have to reset permissions.

If it runs now, you need an editor that saves in Unix format. Macromedia Homesite and HTMLed are two such programs.