title: expect into remote system, get output to local shell variable
body: <p>I am trying to get an expect script to ssh into a remote system, and get the output of a remote command.
  I want to have that output available locally.
  As an example, ssh into the system and get the local time output:</p>
  
  <pre><code>#!/usr/bin/expect --
  set timeout 60
  spawn ssh user@server.domain.com
  expect {
  timeout {puts "timed out after $timeout seconds"; exit}
  "Password:"
  }
  send "SuperSecretPassword\r"
  expect "user$ "
  send "date\r"
  expect "date"
  expect "\r"
  set buffer1 '$expect_out(buffer)'
  expect "\r"
  set buffer2 '$expect_out(buffer)'
  send "exit\r"
  expect eof
  set buffer3 '$expect_out(buffer)'
  exit
  export VARIABLE $buffer1
  export VARIABLE $buffer2
  export VARIABLE $buffer3
  echo "Okay, we are done expecting..."
  echo "Buffer1: $buffer1"
  echo "Buffer2: $buffer2"
  echo "Buffer3: $buffer3"
  </code></pre>
  
  <p>Naturally, the above isnt working, and in fact the script execution ends after the expect "exit"</p>