tags:

views:

84

answers:

4

I am working with a shared hosting environment which as well as other things supports Python. I have followed the examples and deployed my cgi file and then through chmod, gave it Read and Execute Permissions to the world and then Read, Write and Execute to the owner.

The code is simply this:

#!/usr/bin/python

# Required header that tells the browser how to render the text.
print "Content-Type: text/plain\n\n"

# Print a simple message to the display window.
print "Hello, World!\n"

When I then run this I get the following error:

A file permissions error has occurred. Please check the permissions on the script and the directory it is in and try again.

Any help is appreciated!

Andrew

+3  A: 
  1. Make sure the python location is really /usr/bin/python
  2. Give read & execute permissions to all, and write permission to owner: chmod 755 file.py

EDIT: are you getting the error from the command line or in your web browser? The directory could be configured in the web server not to run CGI scripts.

orip
+6  A: 

the account the webserver is running as doesn't have privileges to execute the script, or a directory in the path leading to it.

just somebody
+1 for mentioning the path leading up to it :)
orip
How might one check that? +1 for that!
Isaac Hodes
`ls -al` in the directory in question will generally list the permissions as well as the owner.
Paul McMillan
+1  A: 

Another thing to check: Does the directory you have the script in have ExecCGI permissions (assuming you are running Apache)?

Peter Rowell
A: 

OK, I listened to the tech support, and it would appear that was the biggest problem, lol :-) I was toldnot to put my cgi file in the cgi-bin, and during testing their servers were crashing quite a lot. So after everything has calmed down with the server and it started working again, I placed the file inside the cgi-bin and added the permissions and hey presto it worked.

The new folder/file structure is as follows:

cgi-bin
 - test.cgi
mevadata
public_html
 - index.html

Now it works. I have had very little experience on a linux box, so thank you all for your time and input.

Cheers again,

Andrew

REA_ANDREW