title: Automating ssh login: tcl expect interact command behaves weird
body: <p>I wanted to automate ssh logins. After some research, it seemed like tcl/expect was the route to go.</p>
  
  <p>However, my issue is that when interact takes over my terminal, stuff doesn't work as expected (pun not intended). </p>
  
  <p>For example, if I resize the terminal, it does not "take". Also, sometimes the interact is not responsive, and sometimes it just hangs for no reason. I have included my code below. My question for the code is, am I missing something?</p>
  
  <p>Also, is there a better way to do this (with another scripting language?) I need the terminal to be very responsive, and no different than if I had manually typed ssh on the console.</p>
  
  <pre><code>proc Login {username server password} {
      set prompt "(%|&gt;|\#|\\\$) $"
  
      spawn /usr/bin/ssh $username@$server
      expect { 
          -re "Are you sure you want to continue connecting (yes/no)?" {
              exp_send "yes\r"
              exp_continue 
              #continue to match statements within this expect {}
          }
  
          -nocase "password: " { 
              exp_send "$password\r" 
              interact
          }
      }
  }
  </code></pre>