Python CGIHTTPServer access denied on OS X
Asked Answered
W

1

5

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).

Wasteful answered 20/4, 2013 at 12:55 Comment(0)
W
14

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.

Wasteful answered 20/4, 2013 at 13:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.