2021年3月29日星期一

I have problems with telnetlib python

I can login by telnet in a Nokia Equipment (NE Transport) with a python script, I send a command withouth problemas, but I don´t receive any information from NE, the program freeze and don't receive any error information of python. The code is:

import telnetlib    import sys    import getpass    HOST = "10.0.146.28"    CLI = "cli"    USER = "*******"  PASSWORD = "*****"    Y = "Y"    Command = "help"      tn = telnetlib.Telnet(HOST)    tn.read_until(b"EC1830-81-18 login:", timeout=1)    tn.write(CLI.encode("ascii") + b"\n")    tn.read_until(b"Username:", timeout=1)    tn.write(USER.encode("ascii") + b"\n")    tn.read_until(b"Password:", timeout=1)    tn.write(PASSWORD.encode("ascii") + b"\n")    tn.read_until(b"Do you acknowledge? (Y/N)?", timeout=1)    tn.write(Y.encode("ascii") + b"\n")    print ("Access OK")      tn.write(Command.encode("ascii")  + b"\n")    tn.write(b"exit \n")    resultado = tn.read_all()       

The last command (tn.read_all) is the problem.
I try change with:

resultado = tn.read_all().decode()    resultado = tn.read_all().decode('ascci')    resultado = tn.read_all().decode('utf-8')      

The problem is the same.

Please, can you help me?

Greetings Rudy Meza

https://stackoverflow.com/questions/66860797/i-have-problems-with-telnetlib-python March 30, 2021 at 03:56AM

没有评论:

发表评论