title: how to read command output from serial device using python
body: <p>I have an embedded linux device and here's what I would like to do using python:</p>
  
  <ol>
  <li><p>Get the device console over serial port. I can do it like this:</p>
  
  <p><code>&gt;&gt;&gt; ser = serial.Serial('/dev/ttyUSB-17', 115200, timeout=1)</code></p></li>
  <li><p>Now I want to run a <code>tail</code> command on the embedded device command line, like this:</p>
  
  <p><code># tail -f /var/log/messages</code></p></li>
  </ol>
  
  <p>and capture the o/p and display on my python >>> console.</p>
  
  <p>How do I do that ?</p>