I want to call something like yes "y" | foo bar
, but using subprocess.Popen
. Currently I use this:
yes = subprocess.Popen(['yes', '""'], stdout=subprocess.PIPE)
proc = subprocess.Popen(['foo', 'bar'], stdin=yes.stdout, stdout=subprocess.PIPE)
But, of course, this won't work on Windows. How can I do this so that it works on every platform?