0
我有一個小腳本來執行設備中的命令。我沒有在stdout中獲得命令的輸出,而是在登錄到設備後,在命令提示符之前打印所有這些內容。Paramiko SSH輸出不捕獲命令輸出
import paramiko,
client = paramiko.SSHClient()
client.load_system_host_keys()
client.connect('10.88.124.88', username='admin',password='testing',timeout=15.0)
print "Connected...\n"
print "Executing show version...\n"
stdin, stdout, stderr = client.exec_command("show version")
print "AFTER Executing show version...\n"
stdin.channel.shutdown_write()
print "BEFORE Reading output...\n"
output = stdout.read()
print "AFTER Reading output...\n"
print "OUTPUT:: '", output, "'"
print "Execting quit...\n"
stdin, stdout, stderr = client.exec_command("quit\n")
我從腳本獲得的輸出,如下圖所示。我期待在輸出中輸出「show version」。不知道我失蹤的地方。該設備的響應速度有點慢。
[[email protected] ~]# ./ssh-bana.py
Connected...
...
OUTPUT:: ' Command Line Interface is starting up, please wait ...
verifying connection to main ([email protected])... success
verifying connection to secondary ([email protected])... success
Welcome to the TelePresence Command Line Interface (version 1.1)
Last login: Wed Jun 27 14:45:21 CDT 2012 from 10.88.139.44
admin: '
Execting quit...