Run command pipes with subprocess.Popen
Question: How can I run the following command using
[`subprocess.Popen`](http://docs.python.org/library/subprocess.html#subprocess.Popen)?

    
    
    mysqldump database_name table_name | bzip2 > filename
    

I know [`os.system()`](http://docs.python.org/library/os.html#os.system) can
do the job but I dont want to wait for the dump to finish in main program.


Answer: You want the `shell=True` option to make it 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 yields:

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

