import time
from netmiko import *
import sys
import os
import getpass
# Read the ip address in the iplist.txt file
iplist = open('iplist_cisco.txt', 'r', encoding='ascii')
ip_addr = iplist.readlines()
iplist.close()
cmdlist = open('cmdlist_cisco.txt', 'r', encoding='ascii')
cmd_line = cmdlist.readlines()
cmdlist.close()
# Iterate through the ip_addr list to connect to the ip
for ip in iter(ip_addr):
print(ip)
try:
S5130 = {
'device_type': 'cisco_ios_telnet',
'ip': ip,
'username': 'cisco',
'password': 'cisco',
}
net_connect = ConnectHandler(**S5130)
for cmd in iter(cmd_line):
cmd_result = net_connect.send_command(cmd)
print('-----------------------------------------------------------------')
print(cmd)
print(cmd_result)
print('-----------------------------------------------------------------')
print('')
net_connect.disconnect()
except (EOFError, NetMikoTimeoutException):
print('Can not connect to Device')
except (EOFError, NetMikoAuthenticationException):
print('username/password wrong!')
Read More:
- Python + Requests +Excel+Jenkins interface automation
- Python asynchronous execution library asyncio
- Jupyter notebook Failed to Switch to the Virual Environment: DLL load failed python.exe could not find the entry
- [Solved] ParserError: NULL byte detected. This byte cannot be processed in Python‘s native csv library
- Mac Upgrade pip Error OSError: [Errno 13] Permission denied: ‘/Library/Python/2.7/site-packages/pip-9.0.1-py2….
- [Solved] Python Image Library fails with message “decoder JPEG not available” – PIL
- Invalid python sd, Fatal Python error: init_fs_encoding: failed to get the Python cod [How to Solve]
- [Solved] NPM install Error: check python checking for Python executable python2 in the PATH
- How to Solve pycharm terminal Failed to switch to virtual environment
- How to Solve Python WARNING: Ignoring invalid distribution -ip (e:\python\python_dowmload\lib\site-packages)
- [Solved] opencv-python: recipe for target ‘modules/python3/CMakeFiles/opencv_python3.dir/all‘ failed
- Pyyaml tutorial introduction to pyyaml library and YML writing and reading
- [Solved] Pdfplumber Read PDF Sheet Error: AttributeError: function/symbol ‘ARC4_stream_init‘ not found in library
- [How to Solve] Reason: Incompatible library version
- Nltk Library Download error: [errno: 11004] getaddrinfo failed
- Python raspberry pie starts sending IP address to mailbox
- Linux installs Python and upgrades Python
- HDF5 library version mismatched error [How to Solve]
- Python Error: pip install mysql-connector-python failed
- VScode: How to Solve Pylance Error (pip Library Files Installed)