Jul-01-2019, 04:10 PM
Hi,
Im using a python telnetlib script to communicate with a device.
I want to keep an open connection without exiting. My problem is that i cant read the output before sending the exit command.
Based on the telnetlib documentation i tested with read_very_eager() and read_eager() without success.
An example of the code:
Im using a python telnetlib script to communicate with a device.
I want to keep an open connection without exiting. My problem is that i cant read the output before sending the exit command.
Based on the telnetlib documentation i tested with read_very_eager() and read_eager() without success.
An example of the code:
HOST = "192.168.79.182"
user = "root"
password = "xxx"
tn = telnetlib.Telnet(HOST)
tn.read_until(b"username: ")
tn.write(user.encode('ascii') + b"\n")
if password:
tn.read_until(b"password: ")
tn.write(password.encode('ascii') + b"\n")
tn.write(b'show time\n')
Output = (tn.read_very_eager().decode('ascii'))
print(Output)any ideas would be appreciated
