I am facing with an automation problem in Python. I am pretty new in using the subprocess module that I intend to use for this task. I am working with Python 3.8 and Windows 10. I have a .exe program that I want to run inside a python script. With the following commands:
import sys, string, os, subprocess
from subprocess import PIPE, Popen, STDOUT, STARTUPINFO
s = Popen("my_fortran_code.exe", stdin=PIPE, stdout=PIPE, stderr=PIPE, shell = True)
I successfully start the executable Fortran code but, after that, the code needs some user inputs from the keyboard interactively. I tried to pass the inputs using communicate as follows:
out = s.communicate(input=b'1\n0\n1\nfile_name\n')[0]
but the Fortran code doesn't receive the inputs. Some suggestions about this problem? Thanks a lot!