from twisted.internet import reactor
from twisted.manhole import telnet
def createShellServer( ):
print 'Creating shell server instance'
factory = telnet.ShellFactory()
port = reactor.listenTCP( 2000, factory)
factory.namespace['x'] = 'hello world'
factory.username = 'mike'
factory.password = 'which1ta'
print 'Listening on port 2000'
if __name__ == "__main__":
reactor.callWhenRunning( createShellServer )
Turns out "service" is entirely superfluous, it's just assigned to the variable "service" in the namespace that's created. It's likely good practice to provide a pointer to something service-like (in the general Twisted sense of the word), but it's not actually a functional requirement.
The script above creates a little telnet server on port 2000 with a Python prompt available to you once you log on. You can add whatever you want to the factory.namespace dictionary to make it available to the user. You'd obviously want to use a different username and password, of course ;) .
So far I've been a little underwhelmed with the provided interpreter client, but then I've had to use my sister's machine to do the connecting, and it's telnet client seems a little... confused. Seems there's no per-character return echo? Doesn't seem like that could really be the case, hoping it's a Windows-telnet problem that will go away when I get a chance to install telnet on my workstation.