I have a piece of code that does this:
def command(self, s, level=1): sub=subprocess.Popen(s, bufsize=0, shell=True, stdout=subprocess.PIPE, stderr=su