0

I have the following HTML file located in the /test folder of my website:

<!DOCTYPE html>
<html lang="en">
<body>
    <h1>Enter the texts to be compared</h1>
    <form action="/cgi-bin/test_python.cgi" method="POST">
    <input type="text" name="text1">
    <input type="text" name="text2">
    <input type="submit" name="my-form" value="Check !">
    </form>
</body>
</html>

I have this Python script located in the /cgi-bin folder of my website:

#!/usr/bin/python   
print('Content-type: text/html\r\n\r')

I am able to access the HTML file using a web browser, but pressing the "Check!" button results in a 404 message. The CGI file has 755 execute permissions assigned to it.

This is shared hosting, so I don't know for sure what features are installed or not. But CGI should at least work. I am new to Python. Is there a way to get this setup to work? Thanks.

7
  • What is your python file named? Commented Jun 9, 2018 at 0:24
  • It is named test_python.cgi. Commented Jun 9, 2018 at 0:26
  • If it matters, I am unable to navigate to /usr/bin/python using FTP. It says there is no such file or directory. There appears to be a shortcut or something to a folder /usr/bin/python2, but when I try to go there the FTP program instead downloads a 8KB binary file named python2. Commented Jun 9, 2018 at 0:32
  • 1
    Its a shared hosting, so you don't have access to httpd.conf, but you might have a .htaccess file (or you can create one). But you are getting 404 error, which happens when some file is not where it is supposed to be. Try going to www.yoursite.com/cgi-bin/test-python.cgi directly, and see if you still get the 404 error. Commented Jun 9, 2018 at 2:13
  • 1
    You only need a single .htaccess file, and that in your index folder (/somepath/public_html/ .. or something similar). And as you figured, your cgi files will only execute in cgi-bin folder. Commented Jun 10, 2018 at 2:11

1 Answer 1

1

Check that the cgi-folder itself (not talking about python cgi file) has 755 permissions as well. I think that is the problem here.

Also, try running a sample perl cgi Hello World file: https://practicalperl5.blogspot.com/2014/02/hello-world.html

Sign up to request clarification or add additional context in comments.

3 Comments

The folder is 755 as well. There are a few files already in it, but I don't know what they are for.
The files are: cgiecho, cgiemail, entropybanner.cgi, randhtml.cgi. They appear to be compiled.
It seems, it is better to contact your Host, via email or phone. Sometimes some Admins, disable CGI until explicitly requested, or change the config away from default values.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.