Piping output using subprocess.Popen and subprocess.PIPE
<p>I'm relatively new at python and would really appreciate help regarding its subprocess module.
Using Popen can someone tell me how to pipe the output of process1 (which is the ls command) to process2(which is gedit hello.txt) The code which I use doesn't throw any error, but doesn't pipe the output of ls either. hello.txt is initially blank, and remains blank after the script is executed.</p>

<pre><code>from subprocess import *
a = Popen(['ls'],stdout = PIPE,shell=True)
b = Popen("gedit hello.txt",stdin = a.stdout,shell=True)
</code></pre>

<p>If possible, I would really appreciate it if one of you could explain the general method of how to pipe data. Thanking you in advance.</p>

<p>PS: I've used shell=True because I had read on one of the forums that PIPE needs shell=True to work. </p>