[英]Run command pipes with subprocess.Popen
如何使用subprocess.Popen
運行以下命令?
mysqldump database_name table_name | bzip2 > filename
我知道os.system()
可以完成這項工作,但我不想等待轉儲在主程序中完成。
您希望shell=True
選項使其執行shell命令:
import subprocess
subprocess.Popen("sleep 4s && echo right thar, right thar",shell=True);
print 'i like it when you put it'
產量:
I like it when you put it
[4 seconds later]
right thar, right thar
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.