title: How can I read one line from a telnet response with Python?
body: <p>I was surprised that I couldn't find this question on here. </p>
  
  <p>I would like to take extract one line from a telnet response and make it a variable. (actually one number from that line). I can extract up to where I need using telnet.read_until(), but the whole beginning is still there. The printout shows different statuses of a machine.</p>
  
  <p>The line I am trying to get is formatted like this:</p>
  
  <pre><code>CPU Utilization          : 5 %
  </code></pre>
  
  <p>I really only need the number, but there are many ':' and '%' characters in the rest of the output. Can anyone help me extract this value? Thanks in advance!</p>
  
  <p>Here is my code (this reads the whole output and prints):</p>
  
  <pre><code>import telnetlib, time
  
  
  print ("Starting Client...")
  host    = input("Enter IP Address: ")
  timeout = 120
  
  print ("Connecting...")
  try:
      session = telnetlib.Telnet(host, 23, timeout)
  except socket.timeout:
      print ("socket timeout")
  else:
      print("Sending Commands...")
      session.write("command".encode('ascii') + b"\r")
      print("Reading...")
      output = session.read_until(b"/r/n/r/n#&gt;", timeout )
      session.close()
      print(output)
      print("Done")
  </code></pre>
  
  <p>Edit: some example of what an output could be:</p>
  
  <pre><code>Boot Version         : 1.1.3 (release_82001975_C)
  Post Version         : 1.1.3 (release_82001753_E)
  Product VPD Version  : release_82001754_C
  Product ID           : 0x0076
  Hardware Strapping   : 0x004C
  CPU Utilization      : 5 %
  Uptime               : 185 days, 20 hours, 31 minutes, 29 seconds
  Current Date/Time    : Fri Apr 26 17:50:30 2013
  </code></pre>