title: Running Python With STDIN From Bash
body: <p>I have a bash code (<code>Mybash1.sh</code>) where the result I need to pass 
  to another bash code (<code>Mybash2.sh</code>) that contain Python</p>
  
  <p>Here are the codes. Mybash1.sh </p>
  
  <pre><code>#! /bin/bash
  # Mybash1.sh
  cut -f1,3 input_file.txt | sort | ./Mybash2.sh 
  </code></pre>
  
  <p>Mybash2.sh is this:</p>
  
  <pre><code>#! /bin/bash
  #Mybash2.sh
  python mycode.py foo.txt &lt;("$@") &gt; output.txt
  # do something for output.txt
  </code></pre>
  
  <p>The problem I have is that "output.txt" in <code>Mybash2.sh</code>  contain no result.
  Is there a correct way to execute Python in <code>Mybash2.sh</code>?</p>
  
  <p>Note that <code>mycode.py</code> will work if I run it on an intermediate temporary
  file given from <code>Mybash1.sh</code>. But I wanted to avoid using that, since I will call <code>Mybash2.sh</code>
  in many instances within <code>Mybash1.sh</code>.</p>
  
  <p>Snippet of <code>mycode.py</code> looks like this:</p>
  
  <pre><code>if __name__ == "__main__":
      import sys, os, fileinput
      progName = os.path.basename(sys.argv[0])
      if len(sys.argv) != 3:
          sys.exit('Usage: ' + progName + ' file1 file2')
      file1 = fileinput.input(sys.argv[1])
      file2 = fileinput.input(sys.argv[2])
  
      # do something for file1 and file2
  
      file1.close()
      file2.close()
  </code></pre>