Run command channels with .Popen subprocess

How can I run the following command using subprocess.Popen ?

 mysqldump database_name table_name | bzip2 > filename 

I know os.system() can do this work, but I do not want to wait for the dump to complete in the main program.

+4
source share
1 answer

You want the shell=True parameter to execute shell commands:

 import subprocess subprocess.Popen("sleep 4s && echo right thar, right thar",shell=True); print 'i like it when you put it' 

which gives:

  I like it when you put it [4 seconds later] right thar, right thar 
+6
source

All Articles