JDCyrus Posted January 27, 2010 Share 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? Link to comment Share on other sites More sharing options...
Wizard Posted January 27, 2010 Share Posted January 27, 2010 Post the script here. Link to comment Share on other sites More sharing options...
JDCyrus Posted January 28, 2010 Author Share 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>" Link to comment Share on other sites More sharing options...
Wizard Posted January 28, 2010 Share 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 -*- Link to comment Share on other sites More sharing options...
Wizard Posted January 28, 2010 Share Posted January 28, 2010 This support request is being escalated to our root admin. Link to comment Share on other sites More sharing options...
Byron Posted January 28, 2010 Share 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. Link to comment Share on other sites More sharing options...
JDCyrus Posted January 28, 2010 Author Share 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? Link to comment Share on other sites More sharing options...
Byron Posted January 28, 2010 Share 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. Link to comment Share on other sites More sharing options...
Wizard Posted January 29, 2010 Share 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. Link to comment Share on other sites More sharing options...
JDCyrus Posted January 29, 2010 Author Share 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. Link to comment Share on other sites More sharing options...
Wizard Posted January 29, 2010 Share Posted January 29, 2010 When I ran your code with that added, it worked fine. Link to comment Share on other sites More sharing options...
Ashoat Posted January 29, 2010 Share 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. Link to comment Share on other sites More sharing options...
Byron Posted January 29, 2010 Share 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? Link to comment Share on other sites More sharing options...
Ashoat Posted January 29, 2010 Share Posted January 29, 2010 Oh yeah, you're right. My bad - 755 will actually screw things up. CHMOD .htaccess to 644. Link to comment Share on other sites More sharing options...
noisyscanner Posted February 2, 2010 Share Posted February 2, 2010 CGI scripts should go in the cgi-bin folder and should be chmodded to 755. Hope this helps. Link to comment Share on other sites More sharing options...
Recommended Posts