-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtelnetExampleLoop.py
More file actions
32 lines (29 loc) · 965 Bytes
/
telnetExampleLoop.py
File metadata and controls
32 lines (29 loc) · 965 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#! /bin/bash/python3
# Telnetexample
import getpass
import telnetlib
for Routers in range(2):
HOST = input("Enter the IP Address of Device: ")
print("I am logging int to Router - " + (HOST))
tn = telnetlib.Telnet(HOST)
user = input("Enter your cisco username: ")
password = getpass.getpass()
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"terminal len 0\n")
tn.write(b"configure terminal\n")
# tn.write(b"hostname RTR1\n")
tn.write(b"router eigrp 100\n")
tn.write(b"no auto-summary\n")
tn.write(b"network 0.0.0.0\n")
tn.write(b"exit\n")
tn.write(b"exit\n")
tn.write(b"show ip protocol\n")
tn.write(b"show version\n")
tn.write(b"show ip interface brief\n")
tn.write(b"write memory\n")
tn.write(b"exit\n")
print(tn.read_all().decode('ascii'))