Anyone have a function script using 3.6 for telnet? The script below doesn't accomplish anything.RUnning a debug on the switch I see a telnet attempt but I don't see a login for the user and none of the commands run.
import getpass import sys import telnetlib HOST = "X.X.X.X" # I use the actual IP here. user = input("Enter your Username: ") password = getpass.getpass() print("passed the getpass step") tn = telnetlib.Telnet(HOST) tn.read_until(b"Username: ") tn.write(user.encode('ascii') + b"\n") #tn.write(b"user" + "\n") if password: tn.read_until(b"Password: ") tn.write(password.encode('ascii') + b"\n") # not needed due login privilege 15 to tn.write("enable\n") tn.write(b"config t" + "\n".encode('ascii')) print("config t complete") tn.write(b"interface loopback 0" + "\n".encode('ascii')) print("interface loopback 0") tn.write(b"ip address 1.1.1.1 255.255.255.255" + "\n".encode('ascii')) print("IP address complete") tn.write(b"end" + "\n".encode('ascii')) tn.write(b"exit" + "\n".encode('ascii')) print(tn.read_all().decode('ascii')) input("\n\nPress the enter key to exit.")