python cgi errors and setup

This topic is 4514 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

Now I have just gotten myself a nice new web host, that suport python. I want to use python to write the backend of my site. Now the problem arives, I cant get a single script to work.. *I am pretty fluent in python (from a win32 perspetive only thought) (note the server ownly suports python thought cgi not mod_python. :( ) Anyway. I get a 500 error everytime that I try to run a .py file in my cgi-bin. The file is chmod'ed 755 (tried with 777 no luck) Here is the example:
#!/usr/bin/env python

# Headers and an extra blank line
print 'Content-type: text/html'
print

# Body
print '<html><body><p>Hello World!</p></body></html>'


Now I belive that the first line is the cause to all these problems. Its suposed to point to the python runtime? After looking around the net I saw many diffrent 1lines. Among: #!/usr/bin/python #!/usr/local/bin/python I tried all these to no more success. I get a 500 internal server error each time. Is there any other locations that the webhost might have hidden the python runtime? Or is this not the cause of the problems? Please give me a hand here.

Share on other sites
If you can telnet or ssh to the host, try typing "which python".

Share on other sites
I do not have telnet or ssh connectivity to the server.
Any others?

Share on other sites
Write a non-Python (eg. sh or bash) CGI script to return the output of "which python" [smile]

Share on other sites
Another thing to try:
Make sure your file has unix (\n only) line endings. If saving on windows you'll get \r\n and that'll prevent your script from running (Python doesn't care about this, but the #! line is interpreted before python even starts)

Also, make sure the #! line is at the very beginning of your script (No lines before it, even comments or blank lines)

Have you checked your host's site? They may have a FAQ showing the location of the python binary.

1. 1
Rutin
36
2. 2
3. 3
4. 4
5. 5

• 12
• 14
• 9
• 9
• 14
• Forum Statistics

• Total Topics
633344
• Total Posts
3011435
• Who's Online (See full list)

There are no registered users currently online

×