title: Expect output write to a file
body: <p>I am trying to login to a remote device and write it`s output to a file. I came up with this code. But in rez.txt file i get line "(buffer)"</p>
  
  <p>My code is very basic - from manual, i do not know what is wrong:</p>
  
  <pre><code>/usr/bin/expect &lt;&lt; SSHLOGIN
  
  spawn ssh -l $user $host
  
  set timeout 100
  
  expect {
  "assword: " {
          send "$password\r"
          }
  }
  expect {
  "&gt;" {
          send "?\r"
          }
  }
  expect {
  "?" {
          puts [open rez.txt w] $expect_out(buffer)
          }
  }
  
  expect {
  "&gt;" {
          send "exit\r"
          }
  }
  SSHLOGIN
  </code></pre>