I have an external (i.e., not changeable) program that takes three input values <a>, <b>, and <c>
(prompted).
$ COMMAND
A: <a>
B: <b>
C: <c>
I'd like to call this program using subprocces.run
like this.
result = subprocess.run(
"COMMAND", shell=True, stdout=subprocess.PIPE).stdout.decode('utf-8').split('\n')
How can I pass those input values?
So far, I've tried to do things like this.
(a)
read, write = os.pipe()
os.write(write, "<a>\n")
os.write(write, "<b>\n")
os.write(write, "<c>\n")
os.close(write)
and
result = subprocess.run(
"COMMAND", shell=True, stdout=subprocess.PIPE, input=read).stdout.decode('utf-8').split('\n')
(b)
result = subprocess.run(
"COMMAND", shell=True, stdout=subprocess.PIPE, input="<a>\n<b>\n<c>\n", encoding=ascii).stdout.decode('utf-8').split('\n')
However, I can't get anything to work...