python - 如何在 Python 中使用 UNTAR 命令?
问题描述
我想用python中的命令替换os.system
命令subprocess.call
。
D = "Some string value received at run time"
P = "Some string value received at run time"
Cmd = D + P + "| sudo /bin/tar -xvpPf - 1>> " + LoggerFile
untarCmd = os.WEXITSTATUS(os.system(Cmd))
现在我想os.system
用subprocess.call
命令替换上面的内容。
pCmd = subprocess.Popen(shlex.split(D + P),shell=False,stdout=subprocess.PIPE)
untarCmd = subprocess.call(shlex.split("untarCmd"),shell=False,stdin=pCmd.stdout)
但接收错误
OSError: [Errno 2] No such file or directory
error writing output file
解决方案
推荐阅读
- python - 使用 HTMLTestRunner 模块时发生错误
- reactjs - create-react-app bash: /usr/local/bin/create-react-app: 没有这样的文件或目录
- python - QTableWidget Joint Cells 问题:水平连接一系列单元格后,然后我一般连接单元格,所选单元格发疯
- reactjs - 如何推入与我传递给 api 的主体相对应的数组?
- scala - 我想运行一个 scala 文件并期望输出
- r - 矩阵上的下标数不正确。同时将数据帧中的值分配给矩阵
- swift - 禁用 ObservableObject 中 @Published 变量的发送事件
- java - 每次 Oracle 发布更新时,我是否需要更新 JAVA JDK?
- c# - Winforms 标签页上的关闭按钮
- azure-logic-apps - 如何在逻辑应用程序中创建和格式化 HTML 表格