sagnik Posted September 6, 2014 Share Posted September 6, 2014 Hey I'm Sagnik! I've a problem on Python Scripts. I had a Python Script, when I'm opening the file in the browser, the script is showing as plain text instead of running. I've added the apache handler "cgi-script" as extentions ".cgi .pl .py .perl .ppl" and I've changed the permition of the script to "0755". But it not works. Please help me as soon as possible. Quote Link to comment Share on other sites More sharing options...
yashrs Posted September 6, 2014 Share Posted September 6, 2014 You can use this in the .htaccess file.AddHandler cgi-script .cgi .pl .py .perl .ppl Options +ExecCGI Quote Link to comment Share on other sites More sharing options...
sagnik Posted September 8, 2014 Author Share Posted September 8, 2014 Sir, it doesn't works. When I've added the code to .htaccess file then when I'm opening any of my file, then I'm getting a 500 Internal Server Error. Please help me. Quote Link to comment Share on other sites More sharing options...
yashrs Posted September 8, 2014 Share Posted September 8, 2014 Please provide us the link to the Python script and also the script if possible so that we can identify you the error in your Python script. Quote Link to comment Share on other sites More sharing options...
sagnik Posted September 8, 2014 Author Share Posted September 8, 2014 Python script is notworking whenopenin .py file I'mgetting 500 InternalServer Error. I've set thefile permition of thepython script to "0755"and I've added the code"AddHandler cgi-script .py .cgi .pl .perl" tothe .htaccess file andalso I've added thehandler "cgi-script" as".py .cgi .pl .perl" fromcPanel's "ApacheHandler" section. Yet,I'm getting the "500Internal Server Error".Please Help Me. Also I'veposted this problem onthe HelioNet's "GeneralDiscussion" section. Quote Link to comment Share on other sites More sharing options...
yashrs Posted September 8, 2014 Share Posted September 8, 2014 Merged topics as they were duplicate. Quote Link to comment Share on other sites More sharing options...
sagnik Posted September 8, 2014 Author Share Posted September 8, 2014 Here is the link of my python script:http://www.sgservices.tk/test.pyI'm sorry, I couldn't attach the script because, the uploader field was hidden. Please fix my problem. Quote Link to comment Share on other sites More sharing options...
yashrs Posted September 8, 2014 Share Posted September 8, 2014 You can post the python script in the post too, or upload it to online services like pastebin, etc. Also check in your python script that you have the shebang line #!/usr/bin/python Also, the first line should be always print("Content-Type: text/html\n\n"); Quote Link to comment Share on other sites More sharing options...
sagnik Posted September 8, 2014 Author Share Posted September 8, 2014 here is my python code:#!/usr/bin/pythonprint("Content-Type:text/html\n\n");name=raw_input('Enteryour name:')print ("Hi %s, Let us befriends!" % name);so what is the problem? Quote Link to comment Share on other sites More sharing options...
yashrs Posted September 8, 2014 Share Posted September 8, 2014 This script just works perfectly fine : http://yashrs.heliohost.org/python/sagnik.py, although you will not be able to take input from the user by raw_input() function as Python runs as CGI here. Quote Link to comment Share on other sites More sharing options...
sagnik Posted September 8, 2014 Author Share Posted September 8, 2014 Thank you sir. My script is now running successfully. Quote Link to comment Share on other sites More sharing options...
yashrs Posted September 8, 2014 Share Posted September 8, 2014 You're welcome . Glad your problem got solved. Do tell us if you have any other query. Quote Link to comment Share on other sites More sharing options...
sagnik Posted September 8, 2014 Author Share Posted September 8, 2014 Ok sir, I've problem on ASP.NET. I've recently posted a topic on it. Please check this. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.