[Twisted-Python] How to write a simpletelnet client?

Henning.Ramm at mediapro-gmbh.de Henning.Ramm at mediapro-gmbh.de
Mon Sep 26 12:30:23 EDT 2005


>>I didn't expect that one must handle control codes (your function reponseFunct), I expected the protocol to handle that for me, but anyway, that was no problem (i.e. you solved it before). And with your code I could even switch off the echo (your next thread).

>You don't actually have to do this.  You can implement iac_DO, iac_DONT, iac_WILL, and iac_WONT to handle feature negotiation.

>You can also use twisted.conch.telnet, which presents a slightly more complete API for feature negotiation.

Thank you, I'll look into it. It's better to use ssh anyway.

>>What I don't understand is how to 'inject' some commands and collect their result.
>>What you tried in your "command" function in __main__ can't work, because the protocol has no transport.
>>I don't understand how to get at the Factory's actual protocol instance and its transport.

>Factory's don't have protocol instances, in general.  A factory is responsible for creating between zero and an unlimited number >of instances of a protocol, as they are demanded by established connections.

>Protocol.connectionMade is provided as a hook for application-level logic.  You may want to send your commands from that method.  >When it is invoked, you will have a transport.

Thank you.

I don't understand how connectionMade would help me here - I use it to switch off ECHO, but everything else is in dataReceived to react on prompts. And I've telnet_Command to issue a command (i.e. I queue it while there's no connection), but if I use the Protocol in a Factory, I can't get my hands on it. Perhaps I simply shouldn't use a Factory.

I guess the UDP code you're discussing with Drake Smith will help me further, his task seems similar to mine.

Best regards,
Henning Hraban Ramm
Südkurier Medienhaus / MediaPro
Support/Admin/Development Dept.




More information about the Twisted-Python mailing list