JavaSa JavaSa - 1 year ago 98
Linux Question

Using 7zip with python to create a passsword protected file in a given path

I'm having an error for what seems to be a permissions problem when trying to create a zip file in a specified folder

-folder has the following permissions:
drwxr-xr-x 193 nobody nobody
When trying to launch the following command in python I get the following:

p= subprocess.Popen(['7z','a','-pinfected','-y','/home/John/testfolder/'] + ['test.txt'],stdout=PIPE.subprocess,stderr=PIPE.subprocess)

Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/", line 710, in __init__
errread, errwrite)
File "/usr/local/lib/python2.7/", line 1327, in _execute_child
raise child_exception
OSError: [Errno 13] Permission denied

Any idea what wrong with permissions?

I pretty new to it ,my python runs from /usr/local/bin path

Answer Source

drwxr-xr-x means that:

1] only the directory's owner can list its contents, create new files in it (elevated access) etc.,

2] members of the directory's group and other users can also list its contents, and have simple access to it.

So in fact you don't have to change the directory's permissions unless you know what you are doing, you could just run your script with sudo like sudo python