I have the following shell script that I would like to write in Python (of course grep . is actually a much more complex command):
grep .
#!/bin/bash
p = subprocess.Popen(['grep', '...'], stdin=subprocess.PIPE, stdout=subprocess.PIPE) output, output_err = p.communicate(myfile.read())