Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

did not get last host #4

Open
vietde opened this issue Nov 8, 2017 · 1 comment
Open

did not get last host #4

vietde opened this issue Nov 8, 2017 · 1 comment

Comments

@vietde
Copy link

vietde commented Nov 8, 2017

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.

@sudharshans-s
Copy link

Change "for n in range (36,39):" to "for n in range (36,40):"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants