sagnik Posted September 6, 2014 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.
yashrs Posted September 6, 2014 Posted September 6, 2014 You can use this in the .htaccess file.AddHandler cgi-script .cgi .pl .py .perl .ppl Options +ExecCGI
sagnik Posted September 8, 2014 Author 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.
yashrs Posted September 8, 2014 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.
sagnik Posted September 8, 2014 Author 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.
sagnik Posted September 8, 2014 Author 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.
yashrs Posted September 8, 2014 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");
sagnik Posted September 8, 2014 Author 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?
yashrs Posted September 8, 2014 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.
sagnik Posted September 8, 2014 Author Posted September 8, 2014 Thank you sir. My script is now running successfully.
yashrs Posted September 8, 2014 Posted September 8, 2014 You're welcome . Glad your problem got solved. Do tell us if you have any other query.
sagnik Posted September 8, 2014 Author Posted September 8, 2014 Ok sir, I've problem on ASP.NET. I've recently posted a topic on it. Please check this.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now