您好,登錄后才能下訂單哦!
#!/usr/bin/python
#-*- coding: utf-8 -*-
import re
import paramiko #引入ssh模塊,該模塊需要單獨安裝。
import time
LogTime = time.strftime('%Y-%m-%d_%H-%M-%S')
tftp = raw_input('Please Enter TFTP Sever IP:')
import Hillstone_icmp
action = raw_input('''Please Select Action :
1:Config & Backup;
2:Backup;
Put Your Choose:''')
for line in open("HS_IP_True.txt"):
hostname = line.replace('\n','')
temp = open('HS_temp.txt','w')
port = 22
username = '666666'
password = '666666'
if action == '2':
try:
client = paramiko.SSHClient()
client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
client.connect(hostname, port, username, password, timeout=5)
remote_conn = client.invoke_shell()
remote_conn.send('show version \n')
time.sleep(2)
remote_conn.send('\n')
out = remote_conn.recv(temp)
time.sleep(2)
DeviceName = (re.findall('.*(?=#)',out))[0]
tftp_cli = "export configuration startup to tftp server %s %s-%s..cfg" %(tftp,DeviceName,LogTime)
remote_conn.send(tftp_cli+'\n')
time.sleep(2)
print hostname,'Backup Success !!'
except :
print hostname,'Backup Failed !!'
免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。