I'm running a subprocess in python with
data = subprocess.run(
command,
shell=True,
stderr=subprocess.STDOUT,
text=True
)
however, some of these commands require input from the user. For example, if I were to run
data = subprocess.run(
"""python -c 'input("What is your input?")'""",
shell=True,
stderr=subprocess.STDOUT,
text=True
)
it would hang. For the commands that would be run, there is a way to not accept any input, however that may damage some of the internals since it then has to make assumptions (which are usually wrong). I would like to be able to stream the output to a function as it is generated, as well as be able to pipe in input as it is asked for within the subprocess's run cycle.
However, I've no clue how to do this. If someone could guide me in the right direction, I'd be eternally grateful!