CGI Problem


#1

I’m having problems running a CGI via the web. I made a simple test case.

I have a file called “test.cgi” with the following contents:

#!/bin/sh
echo Content-Type: text/plain
echo
echo IT WORKS

If I type “sh < test.cgi”, it works.

However if I try via the web (i.e. www.mydomain.com/test.cgi) I get the error listed below.

Any suggestions?
Thanks.
-Lars

Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@mydomain.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.


#2

Here is some more info. Checking the logs, this is the error message (not sure what it means)

[Tue Oct 21 16:50:14 2003] [error] [client 128.208.xxx.xxx] Premature end of scr
ipt headers: /blah/blah/test.cgi
[Tue Oct 21 16:50:14 2003] [error] [client 128.208.xxx.xxx] File does not exist:
/blah/blah/internal_error.html


#3

Did you chmod it to 755 ?

:cool: Perl / MySQL / HTML+CSS


#4

Hmm… You were right in narrowing it down to a permission problem, but its not in the way you suggested. The file itself was 755. On further testing it works if I put it in my root directory. If I put it in a sub-directory it fails to work. My sub-directories are set as drwxrwxr-x, which seems correct to me. Am I missing something?

Thanks for your help!!


#5

The directories (which contain CGI scripts) can’t be group writable either.


#6

Yes! That’s it. Thank you very much.