按下面需求的使用python写个脚本 # 使用ncclient获取配置文件并写入zip文件中举个例
请注意,由于缺乏具体的设备信息和配置文件,以下代码仅供参考。您需要根据实际情况进行相应的调整和修改。
from ncclient import manager
import zipfile
# 连接设备
with manager.connect(
host='1.2.3.4',
port=22,
username='username',
password='password',
hostkey_verify=False,
allow_agent=False,
look_for_keys=False
) as m:
# 获取配置文件
config = m.get_config('running').data_xml
# 将配置文件写入zip文件
with zipfile.ZipFile('config.zip', 'w') as myzip:
myzip.writestr('config.xml', config)
print('配置文件已写入zip文件')
``
原文地址: https://www.cveoy.top/t/topic/fh0z 著作权归作者所有。请勿转载和采集!