I can successfully hard code my values as follows below: (my app launches and the parameters are passed and it runs as if I hit enter after manually entering in each parameter as I would if I ran it via command line, inputting the parameters manually and hitting enter after each one):
from subprocess import Popen, PIPE, STDOUT
p = Popen(['C:\\Program Files\\app\\Bin\\current\\myapp.exe'], stdout=PIPE,
stdin=PIPE, stderr=PIPE)
stdout_data = p.communicate(input='13 20180212.log 20180212.txt
20180212fix.txt'.encode("utf-8"))[0]
stdout = p.communicate()[0]
print ("STDOUT:{}".format(stdout))`
But I want to replace these hard coded values with variables and it is not working successfully as follows:
Output prints as follows - and application is open but nothing is happeningC:\Program Files\app\Bin\current\myapp.exe ['13', '20180212.log', '20180212.txt', '20180212fix.txt']
option_num = "13"
date_log = "20180212.log"
date_text = "20180212.text"
date_fix = "20180212.fix"
arguments = [option_num, date_log, date_text, date_fix]
print (arguments)
command = [program_name]
command.extend(arguments)
output = subprocess.Popen(command, stdout=subprocess.PIPE).communicate()[0]
print (output)
No error, the app just receives it all as one line of input instead of processing a return or enter after each variable - and if I look at the process open in Windows Process Explorer, it shows all the parameters being passed at once