import subprocess import yaml print(str(yaml.load(subprocess.check_output("ps aux | grep -i [n]tpd | awk '{print}'", shell=True))).split()) # print(subprocess.check_output(["ps aux | pgrep ntpd | awk '{print $1}'"], shell=True))