0
我能夠使用paramiko打開ssh會話到交換機。能夠輸入命令並獲取相應的輸出。 我的問題是,我想同時輸入許多命令到交換機。但是,在進入新的命令之前,想知道以前的命令已成功進入switch.For例如使用paramiko模塊SSH進入交換機
開關>啓用 開關# 開關#配置牛逼 開關(配置) 輸入第二個命令,直到我見#標誌和第三條命令,直到我看到配置。 以下是我使用
import paramiko
ssh = paramiko.SSHClient()
ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
ssh.connect('ip-address',username='username', password='password')
list =['enable','config t']
command = '\n'.join(list)
#for i in range(len(list)):
print command
stdin,stdout,stderr = ssh.exec_command(command)
print(stdout.read())