Below script is used to run ping test to a destination from all routers.
e.g ip.txt must in same folder where you are
storing you python program.
Note:-
Make sure router IP must be reachable from the machine where python script is
configured.
import telnetlib
import time
user = "test"
password = "test"
ips = [i.strip() for i in open("ip.txt")]
for ip in ips:
telnet = telnetlib.Telnet(ip)
telnet.read_until("Username: ")
telnet.write(user + "\n")
telnet.read_until("Password: ")
telnet.write(password + "\n")
telnet.write("ping 192.168.10.100\n") #< 192.168.10.100 is the destination
time.sleep(1)
telnet.write("exit\n")
print telnet.read_all()
No comments:
Post a Comment