title: Exporting data from expect script
body: <p>so i've written a short expect script which logs into a APC Power Distribution Unit interface via telnet and polls the current ampage.</p>
  
  <pre><code>    #!/usr/bin/expect
      set ip "192.168.0.1"
      set username "myusername"
      set password "mypassword"
      spawn "/bin/bash"
      send "telnet $ip\r"
      expect "*User Name*"
      send "$username\r"
      expect "*Password*"
      send "$password\r"
      expect "*APC*"
      send -- "phReading all current\r"
      expect "*Success*"
      send  "quit\r"
      expect eof
  </code></pre>
  
  <p>The script does its job and I see the amps on screen, displayed like this:</p>
  
  <pre><code>    apc&gt;phReading all current
      E000: Success
      1: 7.5 A
      apc&gt;quit
  </code></pre>
  
  <p>What i need to do is 'export' that 7.5 figure, either to a text file or pass it to a bash script as a variable. </p>
  
  <p>Any ideas on how i can do this?</p>
  
  <p>Thank you!</p>