I am writing a script on python that will connect to a telnet server and write some basic commands. The login part is working fine, so is the "show version" command, but when I write the "quit" command, it types "uit" into telnet.
One thing that did work is writing "qquit", that would enter "quit" into the telnet, but it's inconsistent. Jus to try things out, I tried three "show version" commands, two of them worked, the middle one typed "how version", missing the first letter.
user = "cisco"
password = "cisco"
tn = telnetlib.Telnet(HOST)
tn.read_until(b"Username: ")
tn.write((user + "\n").encode('ascii'))
if password:
tn.read_until(b"Password: ")
tn.write((password + "\n").encode('ascii'))
tn.write(b"show version\n")
tn.write(b"quit\n")
print(tn.read_until(b"quit").decode('ascii'))
Expected output
DPI-testbed-Switch>show version
...
...
...
DPI-testbed-Switch>quit
Actual Output
DPI-testbed-Switch>show version
...
...
...
DPI-testbed-Switch>uit
Translating "uit"...domain server (255.255.255.255)
I would greatly appreciate any help, and am open to any changes that need to be made, so long as I can run commands in a reliable way.