Click to See Complete Forum and Search --> : CGI & Python


kmfan
12-21-2002, 10:46 AM
I wrote a simple Python script to check to see if everything was configured correctly:

#! /usr/bin/python # checked this using console $ which python

#Tell the browser how to render the text
print "Content-Type: text/plain\n\n"

print "Hello, Python!" # print a test string

this will not run in either a browser or the console

console error:

: bad interpeter: No such file or directory

it has to be the right directory i switched over to it:

$ cd /var/www/cgi-bin
[...cgi-bin]$ ./hello.py

from a browser I get:

SERVER ERROR!!

The server encountered an internal error and was unable to complete your request.
Error message:
Premature end of script headers: hello.py
If you think this is a server error, please contact the webmaster
Error 500


I'm not sure what could be going wrong here. I am using Apache as a web server. I have run Perl scripts out of the cgi-bin. Does the python script need to be in the cgi-bin? Is there a problem with the code? PLEASE HELP!!!!!! Thank You