Hi,
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)
tn.set_debuglevel(9)

print tn.read_until("CMTS>")
print tn.read_all()
tn.write("logout\n")
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>
        tn.write("logout\n")
      File "/usr/lib/python2.6/telnetlib.py", line 280, in write
        self.sock.sendall(buffer)
      File "<string>", line 1, in sendall
    socket.error: [Errno 32] Broken pipe

    Process finished with exit code 1

Thanks

Be a part of the DaniWeb community

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