Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Premature end of script headers???? 1

Status
Not open for further replies.

Oxymoron

Technical User
Dec 17, 2000
168
GB
hi
i posted a thread below "CGI doesnt work on Apache".
I took all ur very helpful advice, changed the shebang line etc, but the script still doesnt work.
I looked up the error log, and I get this message: "Premature end of script headers"
What does this mean? and how should I fix it, so as my script works???

Any and all advice would be gratefully received!
(the script is in the previous thread if u want to check it out)

Thankyou all
JoE we are all of us living in the gutter.
But some of us are looking at the stars.
 
Have you tried any other script to see if you get the same error message or if it works at all? This error message you are getting is kind of a catch all for apache not being able to find the header. It could be that it didn't find the file or the file wasn't a cgi script. If you tested with a script you know works but doesn't work on your machine, then we will know that it is in your configs and not the script. Since you are running Windows, your don't need to worry about permissions on your directories and files. You can take care of all that in httpd.conf. You need to tell apache who can do what and where they can do it. The most common way is to use the ScriptAlias directive. It does two things. It makes cgi-bin look like it's in your DocumentRoot and it tells apache to treat EVERYTING in that directory as a script. You can control who has access to these scripts by creating a cgi-bin directory container and using the allow and deny directives. If other scripts work fine and yours doesn't , try "useCGI" after the shebang of your script.
 
This can & will be caused by having ^M's in the .cgi file, ("Caught me out twice today!!").

I'll asume you'r on Unix ?

If you have command prompt access then you can clean up the file with the following: ....
cp realfile.cgi tmpfile.cgi # create an xtra file

tr -d &quot;\015&quot; < tmpfile.cgi > realfile.cgi # cleans file

You probably dont see the ^M's either with vi or more but they are probably there, the instructions above will make sure it's clean.

Good luck
 
That is a very good point tarn. I've had that happen a few times myself. I don't know if it was the solution to Oxymoron's problem but your advice sounds a lot easier then editing those little boogers out by hand. I think that deserves a star. :)
 
or open file in vi and type

:%s/^M//g

to enter the ^M above press ctrl-v ctrl-m

then save the file :wq
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top