Question

I am using a python cgi-script and using it for few webpages on my server, Everything works fine when permission is manually set to 755.

But When i edit with some software for eg coda . It uploads with different permissions so, I have to manually again change the permission . I am sick of doing that every time my

.htaccess file has this thing in it

Options +ExecCGI
AddHandler cgi-script .py

If you have any other alternate or solution to this problem so that i can set like chmod 755 for every .py script or something like that. DO tell.Like any shell script which i can run one time and then do the same. I am using ubuntu 12 server

I tried this, but,

#!/bin/bash
file=`find *.py`
chmod 775 $file

it can be used in bulk.

Was it helpful?

Solution

It seems that the permissions set upon upload are configurable in coda.

Alternatively, you could use inotifywait on the server (from inotify-tools) to add the executable bit whenever the scripts are modified:

$ inotifywait -c -m -e modify -e create -e attrib  path/to/cgi-bin/ \ 
| while read pth; do
    chmod +x "$(echo $pth | awk -F, '{print $1$3}')"
done

Or just while /bin/true; do sleep 5 && chmod 755 path/to/cgi-bin/*.py; done - it shouldn't matter that much.

If you are feeling adventurous, you could also use Python's built-in http server module and a CGIHTTPRequestHandler with an overloaded is_executable() method.

Still, I'm curious to see if this can be handled entirely from the apache config. Cheers.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top