I am working on the below code.
#!/usr/bin/python
import subprocess
import os
cmd = 'python --version'
stdout = subprocess.Popen(cmd, shell = True, stdout = subprocess.PIPE).stdout
ver = stdout.read()
This code is simply printing the python version on the console and the variable ver is not getting any value. Can anyone please help me understand why this is not working?
I had similar code where i am checking whether a process is running on the node or not.
cmd = 'ps -ef | grep cmserver | grep -v grep'
stdout = subprocess.Popen(cmd, shell = True, stdout = subprocess.PIPE).stdout
cmserver = stdout.read()
And here, nothing is printed on the screen and the variable cmserver has the required value.
sys.version_info?