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
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.
(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!
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.