Paramiko 不返回标准输出
Paramiko not returning stdout
我正在使用 Paramiko 从 python 程序发出一些 SSH 命令。我使用的命令是:
stdin, stdout, stderr = client.exec_command('ls')
print stdout
client.close()
但是我得到了相同的输出 - 它看起来像是不同的数据类型。有什么想法吗?绝对不是文件列表!
<paramiko.ChannelFile from <paramiko.Channel 0 (open) window=2097152 -> <paramiko.Transport at 0x801d6750L (cipher aes128-ctr, 128 bits) (active; 1 open channel(s))>>>
谢谢!
哎呀 - 马上就明白了。我忘了在标准输出上执行 readlines()。
所以,在打印语句之前我应该有:
stdout = stdout.readlines()
我正在使用 Paramiko 从 python 程序发出一些 SSH 命令。我使用的命令是:
stdin, stdout, stderr = client.exec_command('ls')
print stdout
client.close()
但是我得到了相同的输出 - 它看起来像是不同的数据类型。有什么想法吗?绝对不是文件列表!
<paramiko.ChannelFile from <paramiko.Channel 0 (open) window=2097152 -> <paramiko.Transport at 0x801d6750L (cipher aes128-ctr, 128 bits) (active; 1 open channel(s))>>>
谢谢!
哎呀 - 马上就明白了。我忘了在标准输出上执行 readlines()。
所以,在打印语句之前我应该有:
stdout = stdout.readlines()