JDCyrus Posted January 27, 2010 Posted January 27, 2010 I have a Python CGI script that I've put in my public_html folder. I set 755 permissions and the header is correct. But when I go to it in my Web browser, it doesn't execute the script; it displays it! How can I fix this?
JDCyrus Posted January 28, 2010 Author Posted January 28, 2010 Post the script here. It's not terribly interesting. #!/usr/bin/python print "Content-type: text/html" print print "<html>" print "<center>Hello World!</center>" print "</html>"
Wizard Posted January 28, 2010 Posted January 28, 2010 I don't actually code with python, but it looks like you're missing this after the crunchbang: # -*- coding: UTF-8 -*-
Wizard Posted January 28, 2010 Posted January 28, 2010 This support request is being escalated to our root admin.
Byron Posted January 28, 2010 Posted January 28, 2010 Try adding this to your htaccess file: AddHandler python-program py AddType application/python py You may need to refresh on that file you were testing after you add that.
JDCyrus Posted January 28, 2010 Author Posted January 28, 2010 I wasn't quite sure what you meant by "refresh on the file", but I reuploaded it and reset 755 permissions. And it still displays the script instead of executing it. Is there anything else I can do?
Byron Posted January 28, 2010 Posted January 28, 2010 I wasn't quite sure what you meant by "refresh on the file", but I reuploaded it and reset 755 permissions. And it still displays the script instead of executing it. Is there anything else I can do? I have no knowledge of python scripting. djbob will have to help you with this.
Wizard Posted January 29, 2010 Posted January 29, 2010 I don't actually code with python, but it looks like you're missing this after the crunchbang: # -*- coding: UTF-8 -*- This.
JDCyrus Posted January 29, 2010 Author Posted January 29, 2010 I don't actually code with python, but it looks like you're missing this after the crunchbang: # -*- coding: UTF-8 -*- This. I already did that.
Wizard Posted January 29, 2010 Posted January 29, 2010 When I ran your code with that added, it worked fine.
Ashoat Posted January 29, 2010 Posted January 29, 2010 CHMOD the following to 755: 1) The directory holding the script and .htaccess file. 2) The .htaccess file. 3) The Python script.
Byron Posted January 29, 2010 Posted January 29, 2010 CHMOD the following to 755: 1) The directory holding the script and .htaccess file. 2) The .htaccess file. 3) The Python script. Correct me if I'm wrong djbob, but shouldn't the permissions for the htaccess file ALWAYS be 644? Isn't it just a text file that's read and not executed?
Ashoat Posted January 29, 2010 Posted January 29, 2010 Oh yeah, you're right. My bad - 755 will actually screw things up. CHMOD .htaccess to 644.
noisyscanner Posted February 2, 2010 Posted February 2, 2010 CGI scripts should go in the cgi-bin folder and should be chmodded to 755. Hope this helps.
Recommended Posts