master, slave = pty.openpty()
p = Popen(cmd, shell=True, stdin=PIPE, stdout=slave, stderr=slave,
    close_fds=True)
stdout = os.fdopen(master)
print(stdout.readline())
print(stdout.readline())
Python Run a daemon sub-process & read stdout