Python Forum
printing out the contents aftre subprocess.call()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
printing out the contents aftre subprocess.call()
#1
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 :

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--------------------- 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?
Reply


Messages In This Thread
printing out the contents aftre subprocess.call() - by Rakshan - Jul-29-2021, 01:45 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  continue if 'subprocess.call' failes tester_V 11 5,214 Aug-26-2021, 12:16 AM
Last Post: tester_V
  printing contents of Jar on timeout Rakshan 1 1,738 Jul-30-2021, 07:48 AM
Last Post: buran
  subprocess call cannot find the file specified RRR 6 16,681 Oct-15-2020, 11:29 AM
Last Post: RRR
  Why wont subprocess call work? steve_shambles 3 2,702 Apr-28-2020, 03:06 PM
Last Post: steve_shambles
  printing a list contents without brackets in a print statement paracelx 1 2,155 Feb-15-2020, 02:15 AM
Last Post: Larz60+
  subprocess.call - Help ! sniper6 0 1,541 Nov-27-2019, 07:42 PM
Last Post: sniper6
  Mock call to subprocess.Popen failing with StopIteration tharpa 7 5,970 Nov-08-2019, 05:00 PM
Last Post: Gribouillis
  Echo call to VLC bash using subprocess.Popen on Linux LuukS001 17 9,734 Jan-07-2019, 03:58 AM
Last Post: LuukS001
  Why is subprocess.call command not working? zBernie 5 10,762 Nov-19-2018, 11:11 PM
Last Post: snippsat
  Help with subprocess..call oldcity 1 2,568 Sep-28-2018, 03:59 PM
Last Post: volcano63

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020