Professional Documents
Culture Documents
New Text Document
New Text Document
router, read input for ssh ip address from txt file, and give output in excel
Here is a Python program that will capture the loopback0, IOS version, and hostname
from a Cisco router using SSH, read the SSH IP address from a text file, and output
the results to an Excel file:
Copy code
import paramiko
import re
import xlsxwriter
# Use regular expressions to extract the loopback0, IOS version, and hostname
loopback0_pattern = r"interface Loopback0\n +ip address (\d+\.\d+\.\d+\.\d+)"
ios_pattern = r"version (\d+\.\d+\.\d+)"
hostname_pattern = r"hostname (\S+)"
loopback0 = re.search(loopback0_pattern, output).group(1)
ios = re.search(ios_pattern, output).group(1)
hostname = re.search(hostname_pattern, output).group(1)
To use this program, you will need to install the paramiko and xlsxwriter
libraries. You can do this by running the following command:
Copy code
pip install paramiko xlsxwriter
I hope this helps! Let me know if you have any questions.