title: Command not write in buffer with Expect
body: <p>I try to backup a Linkproof device with expect script and i have some trouble. It's my first script in expect and i have reach my limits ;)</p>
  
  <pre><code>#!/usr/bin/expect
  spawn ssh @IPADDRESS
  expect "username:"
  # Send the username, and then wait for a password prompt.
  send "@username\r"
  expect "password:"
  # Send the password, and then wait for a shell prompt.
  send "@password\r"
  expect "#"
  # Send the prebuilt command, and then wait for another shell prompt.
  send "system config immediate\r"
  #Send space to pass the pause
  expect -re "^ *--More--\[^\n\r]*"
  send ""
  expect -re "^ *--More--\[^\n\r]*"
  send ""
  expect -re "^ *--More--\[^\n\r]*"
  send ""
  # Capture the results of the command into a variable. This can be displayed, or written to disk.
  sleep 10
  expect -re .*
  set results $expect_out(buffer)
  # Copy buffer in a file
  set config [open linkproof.txt w]
  puts $config $results
  close $config
  # Exit the session.
  expect "#"
  send "logout\r"
  expect eof
  </code></pre>
  
  <p>The content of the output file:</p>
  
  <p>The authenticity of host '@IP (XXX.XXX.XXX.XXX)' can't be established.</p>
  
  <p>RSA key fingerprint is XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX.</p>
  
  <p>Are you sure you want to continue connecting (yes/no)? @username</p>
  
  <p>Please type 'yes' or 'no': @password</p>
  
  <p>Please type 'yes' or 'no': system config immediate</p>
  
  <p>Please type 'yes' or 'no': </p>
  
  <hr>
  
  <p>Like you can see, the result of the command is not in the file. Could you, please, help me to understantd why ?
  Thanks for your help.</p>
  
  <p>Romuald</p>