Python script simply won't run!

matrixsquare

New Member
Messages
4
Reaction score
0
Points
0
Okay, so I made a helloworld.py file and uploaded it into my cgi-bin folder:
#!#!/usr/bin/python

print "Content-Type: text/html"
print
print """\
<html>
<body>
<h2>Hello World!</h2>
</body>
</html>
"""

Looks fine, right? Right. I change the permission to 755 as any sane individual world. Lo and behold, I point my browser to http://mse.x10hosting.com/cgi-bin/helloworld.py and it immediately returns an Internal Server Error 500.

I also tweaked the .htaccess file a bit so that .py files can be run anywhere, my .htaccess file now looks like:
# -FrontPage-

IndexIgnore .htaccess */.??* *~ *# */HEADER* */README* */_vti*

<Limit GET POST>
order deny,allow
deny from all
allow from all
</Limit>
<Limit PUT DELETE>
order deny,allow
deny from all
</Limit>
AuthName mse.x10hosting.com
AuthUserFile /home/mse/public_html/_vti_pvt/service.pwd
AuthGroupFile /home/mse/public_html/_vti_pvt/service.grp
Options +ExecCGI
AddType application/x-httpd-cgi .pl
AddHandler cgi-script .py

The new additions are bolded.

I'm at my wits' end, why the heck is this happening? And more importantly: Is there a solution (there HAS to be! Other users are using Python with x10hosting perfectly fine!)

Thanks in advance for any help, guys :).
Edit:
Hahahaha, I'm laughing my butt off right now... My python scripts will run anywhere BUT in the cgi-bin folder!

Man, who the heck set up Python for these servers :nuts:?

Either way, I'm happy, since I can at least use Python now :biggrin:!
 
Last edited:

marzipun

New Member
Messages
2
Reaction score
0
Points
0
Well now, sir, if it wasn't for your first line:-

#!#!/usr/bin/python

I'd think you were a genius.

I know... I know... you were just checking that we were awake.
 

matrixsquare

New Member
Messages
4
Reaction score
0
Points
0
Well now, sir, if it wasn't for your first line:-

#!#!/usr/bin/python

I'd think you were a genius.

I know... I know... you were just checking that we were awake.
Interesting, I think I was about to type out my script and started with "#!" when I decided to simply copy and paste.

There isn't the double #! in the shebang header in the actual script file (I just double checked).

Also, just for future reference for other people who may run into this problem, I use THIS for the shebang line instead of #!/usr/bin/python:
#!/usr/bin/env python

That should look in the entire environment directory for a runnable python installation; so my guess is that python isn't actually installed in usr/bin/python directory...

Either way, the fact that python scripts doesn't run in the CGI-Bin folder (but runs anywhere else) is still pretty hilarious :lol:.
 

maisouimail

New Member
Messages
1
Reaction score
0
Points
0
Very good work, guys! This was 100% what I needed to know.

This was my first visit to the forums to get help (I am a new user), and I am delighted to see that there are sensible and witty people already here who have built up a useful and friendly community.
 

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Either way, the fact that python scripts doesn't run in the CGI-Bin folder (but runs anywhere else) is still pretty hilarious :lol:.

Python scripts in cgi-bin run for me on Absolut. Which host is your site on?
 

xav0989

Community Public Relation
Community Support
Messages
4,467
Reaction score
95
Points
0
The same script didn't work for me on Stoli.

And I believe you wanted to have
Code:
AddType application/x-httpd-cgi .py
instead of
Code:
AddType application/x-httpd-cgi .pl
 
Last edited:
Top