Python Forum
How to save a show run from a switch?
Thread Rating:
  • 1 Vote(s) - 2 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to save a show run from a switch?
#1
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
Reply
#2
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'))
Reply
#3
Aside from python, how would you get that info?  If you telnet in, is there a command you can run to get the config?
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  how to save to multiple locations during save cubangt 1 542 Oct-23-2023, 10:16 PM
Last Post: deanhystad
  PIL Image im.show() no show! Pedroski55 2 955 Sep-12-2022, 10:19 PM
Last Post: Pedroski55
  PIL Image im.show() no show! Pedroski55 6 4,879 Feb-08-2022, 06:32 AM
Last Post: Pedroski55
  best way to use switch case? korenron 8 2,981 Aug-18-2021, 03:16 PM
Last Post: naughtyCat
  How do I do this? Switch Case? mstichler 4 2,567 Jun-05-2020, 10:27 AM
Last Post: snippsat
  switch limitations MuntyScruntfundle 3 2,368 Jan-27-2019, 06:11 PM
Last Post: aakashjha001

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020