2016-04-03 149 views
-1

我使用Paramiko从python程序发出一些SSH命令。我使用的命令是:Paramiko不返回标准输出

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))>>> 

谢谢!

回答

0

哎呦 - 直了后就明白了。我忘了在stdout上做readlines()。 因此,在印刷声明之前,我应该有: stdout = stdout.readlines()