Yes, I'm sort of a Twisted newbie, so maybe this has an obvious answer, but I'm just not seeing it.<br><br>I have a Twisted program that I need to add in the ability to make a client telnet connection to a remote server and send some commands to it and deal with the data received.
<br><br>In my main program I have this line of code:<br>&nbsp;&nbsp;&nbsp; reactor.connectTCP(&quot;mytelnethost&quot;, 24, Connections.TelnetConnection(&quot;myname of object&quot;,events,&quot;command to run&quot;))<br><br>My Connections.TelnetConnection
 class looks like this:<br><br>from twisted.internet.protocol import Protocol, ReconnectingClientFactory<br>from twisted.conch.telnet import Telnet<br><br>class TelnetClient(Telnet):<br>&nbsp;&nbsp;&nbsp; def connectionMade(self):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;connection made&quot;
<br>&nbsp;&nbsp;&nbsp; self.write(&quot;\r\n&quot;)<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; def write(self, data):<br>&nbsp;&nbsp;&nbsp; print data<br>&nbsp;&nbsp;&nbsp; Telnet._write(self, data+&quot;\r\n&quot;)<br><br>&nbsp;&nbsp;&nbsp; def dataReceived(self, data):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print &quot;received:&quot;, data
<br>&nbsp;&nbsp;&nbsp; if &quot;User Name:&quot; in data:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; self.write(&quot;user&quot;)<br><br>&nbsp;&nbsp;&nbsp; if &quot;Password:&quot; in data:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; self.write(&quot;password&quot;)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp; if &quot;&gt;&quot; in data:<br>
&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; time.sleep(2)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; self.write(&quot;connect&quot;)<br>&nbsp;&nbsp;&nbsp; if &quot;Connector Name:&quot; in data:<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; time.sleep(2)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp; self.write(&quot;another command&quot;)<br><br><br><br>class TelnetConnection(Connection, ReconnectingClientFactory):
<br>&nbsp;&nbsp;&nbsp; &quot;&quot;&quot; Telnets to host:port and executes cmd. cmd &quot;&quot;&quot;<br>&nbsp;&nbsp;&nbsp; protocol = TelnetClient<br>&nbsp;&nbsp;&nbsp; def&nbsp; __init__(self, name, eventQueue, cmd=None): <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Connection.__init__(self, name)<br>
<br>&nbsp;&nbsp;&nbsp; def clientConnectionFailed(self, connector, reason):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'connection failed:', reason.getErrorMessage()<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <br><br>&nbsp;&nbsp;&nbsp; def clientConnectionLost(self, connector, reason):<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print 'connection lost:', 
reason.getErrorMessage()<br><br><br><br>This all works great, except that the command sequence is hard coded in the TelnetClient class. I want to be able to reference the &quot;cmd&quot; parameter, which could be a list of commands to iterate over,etc. But I don't see how I can access the &quot;cmd&quot; parameter that gets passed into the TelnetConnection class from within the TelnetClient class.
<br><br>I'm really desparate for some help, I've been racking my brain on this since yesterday morning.<br><br>Thanks,<br><br>Don<br><br>