How to save a show run from a switch? - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: How to save a show run from a switch? (/thread-5178.html) |
How to save a show run from a switch? - raikone14 - Sep-21-2017 I created a code to Connect through a switch using telnet. It is working, but now I am trying to see the running config and save in a file. The code is not returning the running config or any error. Any idea guys? thank you . https://pastebin.com/mVU24pYf RE: How to save a show run from a switch? - buran - Sep-21-2017 That is OP code import getpass import telnetlib host = "10.8.4.100" user = input("Entre seu usuário") password = getpass.getpass() tn = telnetlib.Telnet(host) tn.read_until(b"username: ") tn.write(user.encode('ascii') + b"\n") if password: tn.read_until(b"Password: ") tn.write(password.encode('ascii') + b"\n") tn.write(b"sh run\n") tn.write(b"exit\n") print(tn.read_all().decode('ascii')) RE: How to save a show run from a switch? - nilamo - Sep-21-2017 Aside from python, how would you get that info? If you telnet in, is there a command you can run to get the config? |