Python CGIHTTPServer access denied on OS X

5.8k views Asked by At

I get this error while trying to trigger a Python script inside CGI from the browser;

Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/CGIHTTPServer.py", line 251, in run_cgi
    os.execve(scriptfile, args, env)
OSError: [Errno 13] Permission denied
1.0.0.127.in-addr.arpa - - [20/Apr/2013 14:51:16] CGI script exit status 0x7f00

I'm not running the main process as root ($ python-32 main.py).

This topic did not seem to work for me.

Making the script executable also didn't work ($ chmod +x index.py, -rwxr-xr-x).

1

There are 1 answers

0
AudioBubble On BEST ANSWER

Finally got it to work. This is the basic script;

index.py

#!/usr/bin/env python
import cgi
print 'Content-Type: text/html\n\n'
print ''
print 'test'

Requirements

  • The file needs to be executable; $ chmod +x index.py
  • The file needs to have #!/usr/bin/env python

Hope it might help someone in the future.