I am pretty new to Python. When i execute the following command to get the total CPU core count on my x86 server using the following python code i get an error as below;
########################Code#######################
#!/usr/bin/python
import os
import re
import subprocess
os.system('clear')
#CPU core count check
flag=0
p = subprocess.Popen(['cat /proc/cpuinfo | grep -i processor | wc -l'], stdout=subprocess.PIPE)
print p.communicate(1)
##############################Output####################
Traceback (most recent call last):
File "./chk_config.py", line 9, in <module>
p = subprocess.Popen(['cat /proc/cpuinfo | grep -i processor | wc -l'], stdout=subprocess.PIPE)
File "/usr/lib64/python2.7/subprocess.py", line 711, in __init__
errread, errwrite)
File "/usr/lib64/python2.7/subprocess.py", line 1327, in _execute_child
raise child_exception
OSError: [Errno 2] No such file or directory
os.popen works, but I don't want to use os.popen since it prints None at the end of the total core count which i want to omit/
Enterkey on your keyboard... Also, you can create code blocks by indenting with four spaces.