[英]Using 7zip with python to create a password 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 testfolder
-folder has the following permissions: drwxr-xr-x 193 nobody nobody When trying to launch the following command in python I get the following: 尝试在指定的文件夹中创建zip文件时,我遇到了一个似乎是权限问题的错误
testfolder
-folder具有以下权限:drwxr-xr-x 193没人没人试图在python中启动以下命令我得到以下内容:
p= subprocess.Popen(['7z','a','-pinfected','-y','/home/John/testfolder/yada.zip'] + ['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/subprocess.py", line 710, in __init__ errread, errwrite) File "/usr/local/lib/python2.7/subprocess.py", 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 我对它很陌生,我的python从/ usr / local / bin路径运行
drwxr-xr-x
means that: drwxr-xr-x
表示:
1] only the directory's owner can list its contents, create new files in it (elevated access) etc., 1]只有目录的所有者可以列出目录的内容,在目录中创建新文件(高权限访问)等,
2] members of the directory's group and other users can also list its contents, and have simple access to it. 2]该目录组的成员和其他用户也可以列出其内容,并可以轻松访问它。
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 my_script.py
. 因此,实际上,除非您知道自己在做什么,否则不必更改目录的权限,您可以像
sudo python my_script.py
一样使用sudo
运行脚本。
尝试更改文件夹的权限,然后查看是否再次出现:
chmod -R 777 /foldername
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.