[Answer]-Read/Write permission for a program run with subprocess?

1👍

The /tmp/myapp directory needs to be created first. If your view function in Django doesn’t show you an error it means that you are not catching it properly.
Try something like this:

response = HttpResponse()
calltxt = subprocess.call(['mkdir','/tmp/myapp'])
response.content = calltxt
return response

Append the function to your urls.py and load it in the browser.
0 means the command executed successfully, 1 means error (this is similar to the $! variable in Bash).

I think it’s not the case but if your Django app is deployed in the Web Server the user that creates files and executes commands out of the Python environment is the one that owns the web server daemon. For instance www-data in Apache.
Thus, it is needed to change permissions for this user also in order to write and execute commands out of their normal scope.

Leave a comment