如何在Python中使用UNTAR命令?

2024-09-30 04:28:25 发布

您现在位置:Python中文网/ 问答频道 /正文

我想用python中的subprocess.call命令替换os.system命令

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))

现在我想用subprocess.call命令替换上面的os.system

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

Tags: run命令cmdstringtimevalueossome

热门问题