title: telnetlib.write() doesn't replicate telnet.interact()
body: <p>I've got this spectrum analyzer from the 90's that has a telnet client on it.  I can telnet in with the Linux telnet CLI, and that works great...controls the machine as expected.</p>
  
  <p>I'd like to automate this thing to do 100's of different measurements in a set-it-and-forget-it style setup, so Python is natural.</p>
  
  <p>I'm looking at the telnetlib module, and am having some conflicting results...mind you, I'm still in the prototyping phase of this, so I'm using iPython to do this work.</p>
  
  <p>Basically, I can connect and enter an interactive client with <code>telnetlib.interact()</code>, and that works just about as well as the Linux telnet CLI.  However, when I copy the exact debug output to the <code>telnetlib.write()</code> method, the instrument doesn't respond.  Actually, it says something like, <code>undefined header</code> in it's diagnostic output, so the message isn't being transmitted to it correctly.</p>
  
  <p>Here's an iPython session output:</p>
  
  <pre><code>In [2]: import telnetlib
  
  In [3]: HOST = "192.168.0.118"
  
  In [4]: tn = telnetlib.Telnet(HOST, "5024")
  
  In [5]: tn.set
  tn.set_debuglevel                   tn.set_option_negotiation_callback  
  
  In [5]: tn.set_debuglevel(2)
  
  In [6]: tn.interact()
  Telnet(192.168.0.118,5024): recv b'Welcome to Telnet SCPI Server: agilent\r\nAgilent Te'
  Welcome to Telnet SCPI Server: agilent
  Agilent TeTelnet(192.168.0.118,5024): recv b'chnologies, N1996A, US45310134, A.02.03\r\n\r\nSCPI&gt;\xff\xfb'
  chnologies, N1996A, US45310134, A.02.03
  
  SCPI&gt;Telnet(192.168.0.118,5024): recv b'\x01\xff\xfb\x03'
  Telnet(192.168.0.118,5024): IAC WILL 1
  Telnet(192.168.0.118,5024): IAC WILL 3
  Telnet(192.168.0.118,5024): recv b'\xff\xfc\x01'
  Telnet(192.168.0.118,5024): IAC WONT 1
  Telnet(192.168.0.118,5024): recv b'\xff\xfc\x03'
  Telnet(192.168.0.118,5024): IAC WONT 3
  freq:star 110khz 
  Telnet(192.168.0.118,5024): send b'freq:star 110khz\n'
  Telnet(192.168.0.118,5024): recv b'SCPI&gt;`
  SCPI&gt;
  </code></pre>
  
  <p>however, if I send the same thing with </p>
  
  <p><code>tn.write(b'freq:star 110khz\n')</code>, </p>
  
  <p>nothing happens...or, if I send </p>
  
  <p><code>tn.write(b'freq:star 110khz\n\n')</code>, </p>
  
  <p>nothing happens...no error messages or anything on the instrument.
  It's like nothing even happened.</p>
  
  <p>I've seen some issues on stackoverflow that indicate that timing is an issue...I have no idea how to fix that other than by adding the <code>tn.set_debuglevel(2)</code> as a workaround to add delay, but this is probably misunderstanding on my part as well.</p>
  
  <p>I do know that this instruments is expecting to see things in character-by-character mode and doesn't say whether is supports line-by-line mode, which is how I assume <code>tn.write(foo)</code> sends stuff.</p>
  
  <p>Any ideas where I'm going wrong?</p>