Skip to content

Instantly share code, notes, and snippets.

@marcelohd
Created April 9, 2020 19:03
Show Gist options
  • Select an option

  • Save marcelohd/5f20be0f89b0244b936edca92e0eb0a4 to your computer and use it in GitHub Desktop.

Select an option

Save marcelohd/5f20be0f89b0244b936edca92e0eb0a4 to your computer and use it in GitHub Desktop.
import getpass
import sys
import telnetlib
host = raw_input("Enter your HOST")
user = raw_input("Entre com o seu usuario: ")
passwd = getpass.getpass()
tel_net = telnetlib.Telnet(host)
tel_net.read_until("Username: ")
tel_net.write(user + "\n")
if passwd:
tel_net.read_until("Password: ")
tel_net.write(passwd + "\n")
tel_net.write("enable\n")
tel_net.write("configure terminal\n")
for n in range(0, 4):
tel_net.write("interface range et" + n + "/" + n + "-" + 3)
tel_net.write("du fu\n")
tel_net.write("end\n")
tel_net.write("exit\n")
print tel_net.read_all()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment