-
Notifications
You must be signed in to change notification settings - Fork 222
Description
Hi David,
I used your script but doesn't do telnet all host. Please check my error:
oot@NetworkAutomation-1:~# ./pythonloopscript
Enter your telnet username: username
Password:
Telnet to host36
Telnet to host37
Telnet to host38
here is my script:
#!/usr/bin/env python
import getpass
import sys
import telnetlib
user = raw_input("Enter your telnet username: ")
password = getpass.getpass()
for n in range (36,39):
print ("Telnet to host") + str(n)
HOST = "192.168.13." + str(n)
tn = telnetlib.Telnet(HOST)
tn.read_until("Username: ")
tn.write(user + "\n")
if password:
tn.read_until("Password: ")
tn.write(password + "\n")
tn.write("conf t\n")
for n in range (2,21):
tn.write("no banner exec ^C " + "\n")
tn.write("no banner incoming ^C " + "\n")
tn.write("no banner login ^C " + "\n")
tn.write("no vlan " + str(n) + "\n")
Thanks.