You have to use subprocess.PIPE
, also, to split the command, you should use shlex.split()
to prevent strange behaviours in some cases:
from subprocess import Popen, PIPE
from shlex import split
p1 = Popen(split("tar -c mydir"), stdout=PIPE)
p2 = Popen(split("md5sum"), stdin=p1.stdout)
But to make an archive and generate its checksum, you should use Python built-in modules tarfile
and hashlib
instead of calling shell commands.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…