Last active
July 14, 2021 15:58
-
-
Save corny/d541d3da50de23c62fd33a08902a3672 to your computer and use it in GitHub Desktop.
Python script to read the MAC table from KTI switches via SSH
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import pexpect | |
import sys | |
prompt = '\S+:/>' | |
s = pexpect.spawn("sshpass", ["-p",'', "ssh", "-l", "admin", "-oStrictHostKeyChecking=no", "-oKexAlgorithms=+diffie-hellman-group1-sha1", sys.argv[1]]) | |
s.expect(prompt) | |
s.send("mac dump\r\n") | |
s.expect("\r\n") | |
s.expect(prompt) | |
print(s.before.decode('utf-8')) | |
s.sendline('logout\r') | |
s.sendeof() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment