forked from Abhishek627/Python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPython Scrip
More file actions
35 lines (31 loc) · 849 Bytes
/
Python Scrip
File metadata and controls
35 lines (31 loc) · 849 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
33
34
35
TELNET
==In Python telnet is implemented by the module telnetlib which has the Telnet class which has the required
methods to establish the connection..
import telnetlib
import time
password = ("cisco")
tn = telnetlib.Telnet("192.168.1.10")
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("enable \n")
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("conf t \n")
time.sleep(1)
tn.write("interface loopback10 \n")
time.sleep(1)
tn.write("ip address 10.1.1.1 255.255.255.0 \n")
time.sleep(1)
tn.write("end \n")
time.sleep(1)
tn.write("exit \n")
print tn.read_very_eager()
print("\nThank You")
output:-
root@deepak:~# python telnet.py
SW1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SW1(config)#interface loopback100
SW1(config-if)#ip address 100.1.1.1 255.255.255.0
SW1(config-if)#end
SW1#