I have problem with very simple telnet connection script.:

import sys
import telnetlib
from telnetlib import Telnet
HOST = 'localhost'
command="clear cable modem reset all"

print "Start telnet connection"

tn = telnetlib.Telnet(HOST)

print tn.read_until("CMTS>")
print tn.read_all()
print tn.read_all()

In pycharm run log i see :

Start telnet connection
    Telnet(localhost,23): recv "\xff\xfb\x01\xff\xfb\x03\xff\xfd'\xff\xfa'\x01\xff\xf0"
    Telnet(localhost,23): IAC WILL 1
    Telnet(localhost,23): IAC WILL 3
    Telnet(localhost,23): IAC DO 39
    Telnet(localhost,23): IAC 250 not recognized
    Telnet(localhost,23): IAC 240 not recognized
    Telnet(localhost,23): recv 'you must support echo and suppress go ahead!'
    Telnet(localhost,23): recv ''
    you must support echo and suppress go ahead!

    Telnet(localhost,23): send 'logout\n'
    Traceback (most recent call last):
      File "/home/oliver/PycharmProjects/untitled/123.py", line 16, in <module>
      File "/usr/lib/python2.6/telnetlib.py", line 280, in write
      File "<string>", line 1, in sendall
    socket.error: [Errno 32] Broken pipe

    Process finished with exit code 1


Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.