Python Telnet formatting?

Jean-Paul Calderone exarkun at divmod.com
Mon Mar 3 00:46:47 EST 2008


On Sat, 1 Mar 2008 16:51:08 -0800 (PST), mentaltruckdriver at gmail.com wrote:
>Hi everyone:
>
>I posted here a couple days ago looking for some help creating a
>Telnet-based chat server. You guys pointed me to Twisted, which has
>solved most of my issues.
>
>However, what I want to do is analyze strings received for keywords
>such as 'listcmds' and have the server return something to the client.
>I know how to do that part, at least.
>
>The issue is, when I use clients like PuTTY, it returns a lot of what
>appears to be formatting (e.g. if I typed Hello, it would return "\xff
>\xfb\x1f\xff\
>xfb \xff\xfb\x18\xff\xfb'\xff\xfd\x01\xff\xfb\x03\xff\xfd\x03Hello".)
>
>How would I go about filtering this stuff out of the strings? The
>thing is too, if I use other Telnet programs like Microsoft Telnet,
>they don't have this formatting, so I want to be able to recognize if
>it does have this formatting and act based on if it does or if it
>doesn't.
>
>Any help is appreciated, I know I'm probably asking too many questions
>already :)

If you're using Twisted's telnet implementation, then all of the telnet
command sequences will be handled separately from the application data.

It might help if you share some of your code.

Jean-Paul



More information about the Python-list mailing list