import subprocess output = subprocess.check_output('pidstat -p ALL'.split(' '), stderr=subprocess.STDOUT, universal_newlines=True) print(output)