Thank you very much Robin for your help.
I have to execute some action if the server is CentOS.
The server_description variable may or may not store CentOS key word among few other words. So I was thinking, if I could execute
"CentOS in server_description which would return either "True" or "False". If it is True, the python would perform some action. I have been advised to store the True or False value in another variable.
My problem is I am unable to store True or False in other variable, say, my_Check.
If I could do that, probably I could use the following -
if my_check == "True":
do_something
else:
do_otherthing
Could you please advice, how I can store a command's output, here, "CentOS in server_description in a variable (or any other python level command later) and use the value of the variable whenever required.
e.g.
server_description = "This is xyz abc of mno CentOS"
my_Check = "CentOS" in server_description
if my_Check == "True":
print("This is CentOS")
else:
print("This is NOT CentOS")
The output I am getting is "This is NOT CentOS"
CentOS 7.4 is OS version and Python 3.4.5
I could do it using shell, but I have been asked to use Python only, as the action to be performed based on the condition, if True or False, is already written in Python.
Please don't consider my objective is to print either CentOS or NOT CentOS, rather some other successfully written python code that I will be pasting in if or else section.
While testing, I found this, but not sure why it is not working...
>>> server_description = "CentOS"
>>> my_Check = "centos" in server_description
>>> my_Check
False
>>> my_Check = "CentOS" in server_description
>>> my_Check
True