第一种telnet - ciscolib备份交换机配置文件:
cisco库安装地址:从Github上面下载,进入安装目录:python setup.py install即可
[root@zabbix609 backupsw]# cat telnet_switch3560.py
# -*- coding: utf-8 -*-
import ciscolib
import time
import datetime
def main():
PASSWORD="123567567"
USERNAME="root"
ENABLE_PWD="123456"
t = datetime.datetime.now()
ot = t.strftime("%Y-%m-%d")
for ip in open('sw3560.txt').readlines():
ip = ip.strip()
if USERNAME != "":
switch = ciscolib.Device(ip, PASSWORD, USERNAME, ENABLE_PWD)
else:
switch = ciscolib.Device(ip, PASSWORD, enable_password=ENABLE_PWD)
try:
switch.connect()
print("Logged into %s,Successful" % ip)
except ciscolib.AuthenticationError as e:
print("Couldn't connect t