Paramiko exec_命令的实时输出实时、命令、Paramiko

由网友(骑猪闯天下)分享简介:注意:我看过有关此问题的其他帖子,但没有一个帖子可以解释答案,也没有一个帖子起作用。有没有办法实时获取exec_command,特别是Paramiko包的exec_command('docker run ')的输出?推荐答案您可以阅读ChannelFile(http://docs.para...

注意:我看过有关此问题的其他帖子,但没有一个帖子可以解释答案,也没有一个帖子起作用。

有没有办法实时获取exec_command,特别是Paramiko包的exec_command('docker run <CONTAINER_ID>')的输出?

推荐答案

win10系统excel怎么才能创建多个独立窗口

您可以阅读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="")
阅读全文

相关推荐

最新文章