I am passing a user input using python subprocess using input in subprocess.run
dargs = ['java','-jar','cli.jar','ion','-cf', config_path, '-r', deldata.get("reg"), '-n', deldata.get("space"), '-e', deldata.get("tion"), '-c', listargs[2], '-f', 'true']
dresp = subprocess.run(dargs, text=True, capture_output=True, input="yes")
This returns following error :
returned non-zero exit status 1.
When calling: subprocess.run(dargs, text=True, capture_output=True, check=True, input="yes")
but the same if I do from terminal it works fine
java -jar cli.jar ion -r DUB -n oa -cf /config/path -e test -c ht -f true
The above command outputs the following and asks for user input like this in terminal
this is force operation.
V Id: sl, Desc: ht
Confirm operation: (yes/no)yes #----->here comes my user input to terminal
Operation done successfully
command triggered from terminal first outputs this two lines
this is force operation.
V Id: sl, Desc: ht
Then waits for sometime and then asks for input Confirm operation: (yes/no)
Not sure how to make subprocess not pipe and send the yes
input rather wait for prompt and check for this line Confirm operation: (yes/no)
and then provide the input as yes
or no
I believe with my current code its performing
yes | java -jar cli.jar ion -r DUB -n oa -cf /config/path -e test -c ht -f true
kind of operation which is not excepted by cli.
Any help on how to achieve this will be great