我想使用python子进程运行以下命令。
ibmzcontainers/hpvs-cli-installer:1.2.0.1.s390x运行--rm -it -v $(pwd):/grep11-cli/config docker加密列表| grep 'cex4queue":[]‘
如果我使用subprocess.call()运行-它可以工作。但是我不能检查返回值
grep“docker run --rm ibmzcontainers/hpvs-cli-installer:1.2.0.1.s390x s1= $(pwd):/grep11-cli/config -it -v |grep \'cex4queue\":[]\'”p1 = subprocess.call(s1,shell=True)
与subprocess.run相同的命令不起作用。
我想检查一下那个字符串是否存在。我该怎么检查呢?
发布于 2020-04-16 20:08:10
我建议使用subprocess.Popem
import subprocess as sb
process = sb.Popen("docker run --rm -it -v $(pwd):/grep11-cli/config ibmzcontainers/hpvs-cli-installer:1.2.0.1.s390x crypto list | grep 'cex4queue\": []'".split(), stdout=sb.PIPE, stderror=sb.PIPE)
output, errors = process.communicate()
print('The output is: {}\n\nThe errors were: {}'.format(output, errors))https://stackoverflow.com/questions/61249737
复制相似问题