p = Popen(cmd, stdout=PIPE, stderr=PIPE) while p.poll() is None: for line in p.stdout: print line ,