I\'m trying to use Python to automate a process that involves calling a Fortran executable and submitting some user inputs. I\'ve spent a few hours reading through similar
If the input doesn't depend on the previous answers then you could pass them all at once using .communicate():
import os
from subprocess import Popen, PIPE
p = Popen('fortranExecutable', stdin=PIPE) #NOTE: no shell=True here
p.communicate(os.linesep.join(["input 1", "input 2"]))
.communicate() waits for process to terminate therefore you may call it at most once.