我一直在开发打开cmd的软件,让其他用户像ssh一样控制它。我希望这能尊重像cd这样的东西,而不仅仅是抛弃它们,就像使用多个进程一样;所以我使用了一个子流程。但是,当尝试多次输出子流程的输出时出现问题:它只返回“”!请帮忙!
相关代码:
print("attempting to open subprocesses")
process = Popen("echo \"im alive!\"", shell=True, stdin=PIPE, stdout=PIPE)
process.wait()
process.stdin.write(bytes(data, "utf-8"))
process.wait()
while True:
print("..inloop")
output = process.stdout.readline().decode("utf-8")
if output == '' and process.poll() is not None:
break
if output:
print("outputting")
hc.broadcast_data("sentinelkey", output, connections,
server_socket)