import subprocess import os import time def command(command): ar = [] command = command.split(" ") for c in command: ar.append(c) process = subprocess.Popen(ar, stdout=subprocess.PIPE,stderr=subprocess.PIPE) p=process.poll() output = process.communicate()[0] print(output) command('echo hello') command('python runtest.py')