Aug-31-2018, 09:01 AM
(This post was last modified: Aug-31-2018, 09:36 AM by Gribouillis.)
Hello,
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
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
Output: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 1.1.1.1 YES manual up up
Loopback1 2.2.2.2 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 = "71.61.14.36" tn = telnetlib.Telnet(HOST, "33153",) print ("Telnetting to device") tn2 = telnetlib.Telnet(HOST, "33154",) print ("Telnetting to device") print ("Executing commands") tn.write("\n\n\n\n") tn.write("\n\n\n\n") tn.write("enable\n") tn.write("show ip interface brief\n") tn.write("show interfaces description\n") print ("Executing commands") tn2.write("\n\n\n\n") tn2.write("\n\n\n\n") tn2.write("enable\n") tn2.write("show ip interface brief\n") tn2.write("show interfaces description\n") tn2.close()