title: sort and uniq in python
body: <p>I want to do some shell command in python. I have a main.py, which call successive function and I find some of them easier to do in shell. The problem : I want to do all of this automatically !</p>
  
  <p>I want to do this kind of code : </p>
  
  <pre><code>sort fileIn | uniq &gt; fileOut
  </code></pre>
  
  <p>my problem is to do it with the pipe caracter. I try :</p>
  
  <pre><code>from subprocess import call
  call(['sort ',FileOut,'|',' uniq '])
  </code></pre>
  
  <p>or</p>
  
  <pre><code> p1 = subprocess.Popen(['sort ', FileOut], stdout=subprocess.PIPE)
  p2 = subprocess.Popen([" wc","-l"], stdin=p1.stdout, stdout=subprocess.PIPE)
  p1.stdout.close()  # Allow p1 to receive a SIGPIPE if p2 exits.
  output,err = p2.communicate()
  </code></pre>
  
  <p>But all of this didn't work. 
  (NB: FileOut is a string)</p>