you can also use pgrep
, in prgep
you can also give pattern for match
import subprocess
child = subprocess.Popen(['pgrep','program_name'], stdout=subprocess.PIPE, shell=True)
result = child.communicate()[0]
you can also use awk
with ps like this
ps aux | awk '/name/{print $2}'