title: Expect command output to be stored in a variable
body: <p>I have written below script .</p>
  
  <hr>
  
  <pre><code>#! /usr/bin/expect
  set timeout 180
  spawn /vobs/iov/rnc/bin/moshell/moshell -d db.dat
  expect {
    -re "OFFLINE_DB.DAT.*" { }
          timeout        { 
       error "\n######## Timeout - when logging in\n"
   }
          eof            { 
       error "\n######## eof - when logging in\n"
   } 
  }
  
  set db_prompt "SQL&gt;"
  send "select id from motype_r1 where data = 'PlugInUnit';\r"
  expect {
    -re "OFFLINE_DB.DAT&gt;"  
  }    
   exit
  </code></pre>
  
  <hr>
  
  <p>Now , I want to get the output of the table in a variable i.e </p>
  
  <pre><code>+------+
  | id   |
  +------+
  |   19 |
  +------+
  Query Done: 1 record selected
  </code></pre>
  
  <p>and match regular expression to get '19' in one more varible.</p>
  
  <p>Can anybody please help me with the solution.</p>
  
  <p>/Akshya </p>