Python Forum
how to do comparison for the value returned by os.system
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how to do comparison for the value returned by os.system
#1
In my code, I’m trying to compare the output returned by the os.system(’/opt/abc/cmd/abc-target’)

Here’s my code:

import os
s= os.system(’/opt/abc/cmd/abc-target’)
if (s == ‘abc’ ):
print (‘great you found the target system’)

The above code doesn’t throw any error but doesn’t execute the if statement. I want the comparison to match and print success.
Please help me understand what I'm doing wrong.
Reply


Messages In This Thread
how to do comparison for the value returned by os.system - by jash - Nov-10-2017, 10:34 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  How to access values returned from inquirer cspower 6 832 Dec-26-2023, 09:34 PM
Last Post: cspower
  SQLAlchemy Object Missing when Null is returned Personne 1 1,752 Feb-19-2022, 02:50 AM
Last Post: Larz60+
  Getting "name 'get_weather' is not defined error and no json_data returned? trthskr4 6 3,655 Sep-14-2021, 09:55 AM
Last Post: trthskr4
  Libraries installed with pipenv, but ModuleNotFoundError returned jpncsu 2 3,019 Sep-06-2021, 07:24 PM
Last Post: jpncsu
  Difference between os.system("clear") and os.system("cls") chmsrohit 7 16,661 Jan-11-2021, 06:30 PM
Last Post: ykumar34
  Exception: Returned Type Mismatch Error devansing 1 5,173 Mar-06-2020, 07:26 PM
Last Post: ndc85430
  How to use a returned value? t4keheart 12 4,903 Jan-16-2020, 06:54 AM
Last Post: perfringo
  Strange Characters in JSON returned string fioranosnake 4 5,233 Dec-02-2019, 07:25 PM
Last Post: fioranosnake
Question Difference between Python's os.system and Perl's system command Agile741 13 6,863 Dec-02-2019, 04:41 PM
Last Post: Agile741
  Not all data returned from sys.argv ecdhyne 2 2,774 Sep-05-2019, 08:27 PM
Last Post: buran

Forum Jump:

User Panel Messages

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