Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Save outputs to Desktop

I wrote my first script.
It is logging to 2 Router's console\CLI and executing few commands.
Afterwards in Router's console I have outputs which shows me for example IP Addresing
R1#sho ip int bri Interface IP-Address OK? Method Status Protocol Ethernet0/0 unassigned YES unset administratively down down Ethernet0/1 unassigned YES unset administratively down down Ethernet0/2 unassigned YES unset administratively down down Ethernet0/3 unassigned YES unset administratively down down Loopback0 YES manual up up Loopback1 YES manual up up R1#show interface description Interface Status Protocol Description Et0/0 admin down down Et0/1 admin down down Et0/2 admin down down Et0/3 admin down down Lo0 up up Lo1 up up R1#
My question is how to save those outputs to my Desktop in text document format.

import getpass
import sys
import telnetlib

print ("Script starts")

HOST = ""

tn = telnetlib.Telnet(HOST, "33153",)
print ("Telnetting to device")

tn2 = telnetlib.Telnet(HOST, "33154",)
print ("Telnetting to device")

print ("Executing commands")
tn.write("show ip interface brief\n")
tn.write("show interfaces description\n")

print ("Executing commands")
tn2.write("show ip interface brief\n")
tn2.write("show interfaces description\n")
I don't have the answer, but there is an impressive wrapper of telnetlib with logging capabilities in the robotframework source code, you could perhaps find ideas here.

Possibly Related Threads…
Thread Author Replies Views Last Post
  Combining outputs into a dataframe rybina 0 267 Mar-15-2021, 02:43 PM
Last Post: rybina
  ONE input => THREE outputs Tricia279 6 487 Jan-14-2021, 08:52 AM
Last Post: perfringo
  Multi set string inputs/outputs kwmcgreal 2 528 Sep-26-2020, 10:44 PM
Last Post: kwmcgreal
  How to use subprocess to get multiple data outputs in desired folder? 3SG14 1 570 Sep-19-2020, 05:46 PM
Last Post: bowlofred
  Outputs missing SamAnw 4 739 Feb-12-2020, 04:32 PM
Last Post: adetheheat
  Interpreter and running a .py file give different outputs PythonNPC 5 1,054 Jul-21-2019, 01:07 PM
Last Post: PythonNPC
  Help Editing/Problem with outputs stanthaman42 7 1,991 Jul-11-2018, 05:30 PM
Last Post: ichabod801
  how do i rewrite this code to give me 10 outputs BlackPimpernel 2 1,277 Mar-29-2018, 11:29 AM
Last Post: BlackPimpernel
  Different outputs in Python2 and Python3 MikeHill 3 2,323 Jun-07-2017, 08:58 PM
Last Post: Ofnuts
  Program that outputs HQ addresses of companies from Google + Local pages frenchgirl1309 2 2,654 Nov-14-2016, 10:11 PM
Last Post: Ofnuts

Forum Jump:

User Panel Messages

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