title: Linux Expect SSH hangs
body: <p>I tried to install R across a cluster of computers and someone told me to check out Expect.</p>
  
  <p>I was following a tutorial about Linux Expect Command to automate the process of ssh into node and install open source R automatically. </p>
  
  <p>I am kind of stuck on the ssh part:
  (<a href="http://linuxaria.com/howto/2-practical-examples-of-expect-on-the-linux-cli?lang=en" rel="nofollow">Tutorial goes here</a>) </p>
  
  <pre><code>#!/usr/bin/expect -f 
  
  if {[llength $argv] != 3} {
  puts "usage: ssh.exp username server password"
  exit 1
  }
  
  set username [lrange $argv 0 0]
  set server [lrange $argv 1 1]
  set password [lrange $argv 2 2]
  
  set timeout 60
  
  spawn ssh $username@$server.mycompany.com
  
  match_max 100000
  
  expect "*?assword:*"
  
  send -- "$password\r"
  
  send -- "\r"
  
  expect eof
  </code></pre>
  
  <p>I can run the code and log into the remote server, however, I type in ls and it just hangs on the remote server side. And I ctrl + c and it log out and goes back to my host server. </p>
  
  <p>Can any one tell me how to continue the process in Expect after you log in. </p>
  
  <p>Update: Due to Ireeder's answer. </p>
  
  <p>You just need to replace expect eof with interact and it will hand over the control to the user. </p>