Python Forum
subprocess - get exit status of command run on different machine using rsh
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
subprocess - get exit status of command run on different machine using rsh
#1
I am trying to run some commands on some machine which i am connecting through rsh command(cant use ssh here).
Through subprocess.check_call function, i am executing the command & expecting check_call to exit with exception when exit status of my " cd /libs/ " command fails.

with open('logs.txt','w') as outstream:
    subprocess.check_call("rsh bldr 'cd /libs/' ", shell=True,stdout=outstream)
But here rsh returns only its exit status and not the command its executing.
Because of which even in command failure case no error from check_call function, as it is getting rsh exit status which will be 0.

So, how to get the exit status of the command here?
And also how to make check_call fail based on my command exit status?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Basic Coding Question: Exit Program Command? RockBlok 3 655 Nov-19-2023, 06:31 PM
Last Post: deanhystad
  Using subprocess to execute complex command with many arguments medatib531 5 2,007 Apr-27-2023, 02:23 PM
Last Post: medatib531
  fetching exit status hangs in paramiko saisankalpj 3 1,247 Dec-04-2022, 12:21 AM
Last Post: nilamo
  python difference between sys.exit and exit() mg24 1 1,921 Nov-12-2022, 01:37 PM
Last Post: deanhystad
  use subprocess on linux\pi wwith a "grep " command korenron 2 8,308 Oct-19-2021, 10:52 AM
Last Post: DeaD_EyE
  ERROR: Command errored out with exit status 1 calesii 3 7,250 Oct-23-2020, 05:39 PM
Last Post: snippsat
  Error when running mktorrent subprocess command pythonnewbie138 4 3,952 Sep-16-2020, 01:55 AM
Last Post: pythonnewbie138
  Select correct item from list for subprocess command pythonnewbie138 6 3,388 Jul-24-2020, 09:09 PM
Last Post: pythonnewbie138
  "pip install -e ." returns : ERROR: Command errored out with exit status 1 mostafaPython 3 5,568 Jun-09-2020, 09:28 AM
Last Post: snippsat
  Subprocess command working for one cmd and for cmd one not wrking PythonBeginner_2020 0 4,174 Mar-25-2020, 01:52 PM
Last Post: PythonBeginner_2020

Forum Jump:

User Panel Messages

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