Need some help with following code - I want to pass string elements of three list as input to java program that I am calling in my python script. Here is what I have done so far -
import subprocess
from subprocess import PIPE
from subprocess import Popen
amount = ['23.5', '12.5', '56.0', '176.1']
invoice_no = ['11290', '12892', '12802', '23489']
date = ['2/3/19', '12/30/17', '04/21/2018', '8/12/17', '12/21/18']
## problem is proc.communicate(). I am currently passing only invoice_no[i] as input.
for i in range (0, len(invoice_no)):
proc = subprocess.Popen(['java', '-jar', '/data/python/xyz.jar'],stdin=PIPE,stdout=PIPE, stderr=STDOUT)
q = proc.communicate(input = invoice_no[i])
print(q)
## But I want to pass amount and date as input as well.
## I dont know the syntax for that. I also want output as 1 or 0 i.e success or failure. Does anyone know syntax for this?
Most of the questions which I have seen are passing single string as input.But that's not what I am looking for. Even official document of subprocess is not helpful in finding out how to pass multiple inputs syntax. Links are - running java program from python script
How to execute java program using python considering inputs and outputs both