Skip to content

Instantly share code, notes, and snippets.

@corny
Last active July 14, 2021 15:58
Show Gist options
  • Save corny/d541d3da50de23c62fd33a08902a3672 to your computer and use it in GitHub Desktop.
Save corny/d541d3da50de23c62fd33a08902a3672 to your computer and use it in GitHub Desktop.
Python script to read the MAC table from KTI switches via SSH
#!/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