Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions Python Scrip
Original file line number Diff line number Diff line change
@@ -0,0 +1,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#