Skip to content

did not get last host #4

Description

@vietde

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions