Telnet server implementation

Andrew Bennetts andrew-pythonlist at puzzling.org
Tue Dec 2 13:05:02 CET 2003


On Tue, Dec 02, 2003 at 03:49:23AM -0800, kumar wrote:
> Hi all,
> 
> I want to write a telnet server for an embedded linux box using
> python.The problem is that it doesn't give a shell ( just a limited
> CLI commands for configuring it . )My requirement is to write a telnet
> server ( residing on the box) listening on some specific port where it
> can listen to telnet requests from clients and provide them an
> interactive command line session. I tried using the python's
> async_chat module but it is very limited ..any wrappers around this
> module  so that it can be used more interactively ??  . Any pointers
> would be highly appreciated . The current available CLI on this box
> allows me to write python scripts remotely , ftp it and run them, so
> executing them won't be  problem.

You should be able to use Twisted's telnet implementation for this.  There's
an implementation included where the command line session is a pseudo-python
interactive interpreter, which is implemented in twisted/manhole/telnet.py,
the Shell and ShellFactory classes.  

You easily can see this in action by running Twisted's mktap and twistd
commands:

     mktap telnet --port 4040 --username foo --password bar
     twistd -nf telnet.tap

You should be able to figure out how to implement your own telnet command
interpreter in Twisted by reading that code -- if not, please ask for help
on twisted-python at twistedmatrix.com

-Andrew.






More information about the Python-list mailing list