首页 > 解决方案 > subprocess.check_call 抛出 FileNotFoundError 即使文件存在

问题描述

我正在尝试编辑该frida-ios-dump项目以在我的 PC 上实际工作,我目前遇到了一个奇怪的问题,我认为这与权限有关。

chmod_dir = os.path.join(PAYLOAD_PATH, os.path.basename(dump_path))
chmod_args = ('chmod', '655', chmod_dir)
try:
    subprocess.check_call(chmod_args)
except subprocess.CalledProcessError as err:
    print(err)

这段代码在这里抛出了这个错误:FileNotFoundError: [WinError 2] The system cannot find the file specified但我有一种很好的感觉,那个文件确实存在,所以我添加了以下内容except

except FileNotFoundError:
    print(chmod_dir)
    print("FileNotFound, yet path exists: " + str(os.path.exists(chmod_dir)))

正如怀疑的那样,该文件确实存在!我的代码打印FileNotFound, yet path exists: True 并且由于我还打印了路径,我们可以在这里看到:C:\Users\Admin\AppData\Local\Temp\Payload\protobuf.fid并且在手动访问该文件夹时,我确认该文件确实存在于那里。

我有一种强烈的感觉,这是一些权限问题,但我不确定我能做些什么来解决它。

注意: Python 脚本是从 Windows PowerShell 运行的,而 Windows PowerShell 又以管理员权限打开。

标签: pythonwindowspermissionssubprocessfrida

解决方案


推荐阅读