files_to_change_permissions = [ '/etc/passwd', '/etc/group', '/etc/shadow' ] for file_path in files_to_change_permissions: command = 'chmod 644 {}'.format(file_path) subprocess.call(command, shell=True)
时间: 2024-04-14 19:25:46 浏览: 138
你的代码几乎正确,只是在使用`subprocess.call`时需要将命令作为字符串列表传递。以下是修正后的代码:
```python
import subprocess
files_to_change_permissions = [
'/etc/passwd',
'/etc/group',
'/etc/shadow'
]
for file_path in files_to_change_permissions:
command = ['chmod', '644', file_path]
subprocess.call(command)
```
上述代码将遍历`files_to_change_permissions`列表中的文件路径,并使用`chmod`命令将文件权限更改为644。
请确保你具有足够的权限来更改文件权限,并将需要更改权限的文件路径添加到`files_to_change_permissions`列表中。运行代码后,文件的权限将被更改为644。
相关问题
if (NEUSAR_SDK_PATH) install(FILES ${NEUSAR_SDK_PATH}/usr/NeuSAR_ARA_Version PERMISSIONS OWNER_READ GROUP_READ WORLD_READ DESTINATION opt/s2sreader/etc) endif()
如果`NEUSAR_SDK_PATH`变量存在的话,将`${NEUSAR_SDK_PATH}/usr/NeuSAR_ARA_Version`文件安装到`opt/s2sreader/etc`目录中,并设置文件的权限为OWNER_READ、GROUP_READ和WORLD_READ。
请确保`${NEUSAR_SDK_PATH}/usr/NeuSAR_ARA_Version`文件存在,并且`${NEUSAR_SDK_PATH}`变量已经定义。安装完成后,该文件将复制到`opt/s2sreader/etc`目录,并设置相应的权限。
denied { getattr } for path="/storage/emulated/0/Android/data/com.mxy.mdm_demo/files/
Unfortunately, as an AI language model, I do not have the context to fully understand the situation you are experiencing. However, based on the error message you provided, it seems that your application is being denied access to a specific file path on an Android device. This could be due to several reasons, such as permissions not being granted or the file being locked by another process. Please provide more information or consult the Android developer documentation for further assistance.
阅读全文