Jul-29-2021, 01:45 PM
I am facing a scenario where in I need to execute a jar based on user parameters. I have replicated the scenario here as below :
Could anyone guide me here?
import subprocess
a = input('Enter either 2 or 3:')
value = int(a)
if a == 2:
p1 = subprocess.run(['java', '-jar', 'SimpleClient.jar', '-info'], capture_output=True)
print(p1.stdout.decode())
else:
p1 = subprocess.run(['java', '-jar', 'SimpleClient.jar'], capture_output=True)
print(p1.stdout.decode())
print('-----------stdout---------------------')
print('-----------code---------------------')
print(p1.returncode)What I observe is that the print function does not execute. I expect it to show different results based on my entry.Error:Enter either 2 or 3: 2
-----------stdout---------------------
-----------code---------------------
0I had a doubt if p1 is only within the if and else scope. I put the print stattements even inside those clauses. But that does not help either.Could anyone guide me here?
