注意到:我见过其他关于这个问题的帖子,但是没有一个帖子能解释这个答案,也没有一个能起作用的帖子。
是否有一种方法可以获得exec_command的输出,特别是为Paramiko包实时获取exec_command('docker run <CONTAINER_ID>')的输出?
发布于 2019-04-12 11:12:16
您可以从ChannelFile (http://docs.paramiko.org/en/2.4/api/channel.html?highlight=stdout#paramiko.channel.ChannelFile)中读取行。
示例:
stdin, stdout, stderr = client.exec_command('docker run <CONTAINER_ID>')
while True:
line = stdout.readline()
if not line:
break
print(line, end="")https://stackoverflow.com/questions/55642555
复制相似问题