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 :
What I observe is that the print function does not execute. I expect it to show different results based on my entry.
Could anyone guide me here?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
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) |
Error:Enter either 2 or 3: 2
-----------stdout---------------------
-----------code---------------------
0
I 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?