How to get python running?

Status
Not open for further replies.

Kugel

New Member
Messages
3
Reaction score
0
Points
0
here is my script:
Code:
#!/usr/bin/python
print "Python - OK"

And when I try to load the page:
Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, webmaster@bubu.exofire.net 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.


yes, the script is in public_html/cgi-bin/ directory
and yes I have chmoded it to 755

Is there perhaps a log where I can see what the internal error is?
 

tnl2k7

Banned
Messages
3,131
Reaction score
0
Points
0
Try the cPanel Error Log, it has information about most issues.

-Luke.
 

Corey

I Break Things
Staff member
Messages
34,551
Reaction score
204
Points
63
I don't see a shebang in your file.

-Corey
 

Kugel

New Member
Messages
3
Reaction score
0
Points
0
http://bubu.exofire.net/cgi-bin/hello.py

definitely contains shebang

here is the code:
Code:
#!/usr/bin/python

print "Content-Type: text/plain\n\n"

print "test"


EDIT:

Fount the problem, the file was in UTF-8 with BOM.

For anyone who will try to setup python here are the steps:
1) have your files in cgi-bin directory
2) chmod them to 755
3) make sure you have correct shebang line: #!usr/bin/python
4) print text/html line and one extra empty line (see above)
5) I used windows notepad, which saved BOM in my source code, BOM is a 2-3 bytes at the beginning of the file and thus shebang will be corrupted. Save without UTF-8 without BOM or save in ANSI.
 
Last edited:
Status
Not open for further replies.
Top