title: Why does my Expect script only echo the command not running?
body: <p>I'm trying to automate some <code>ssh</code> process. I have my Expect code. But my Expect code only echos/prints out the command. It doesn't actually run the command.</p>
  
  <pre><code>#!/usr/bin/expect -f
  
  set timeout 10
  set usrnm "aaaaaa"
  set pwd "pppppp"
  set addr1 "xxx.cloud.xxx.com -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
  set addr2 "xxx.xxxx.xxxx.com"
  
  spawn ssh $usrnm@$addr1
  
  expect {
  
      "(yes/no)?" {send "yes\r";exp_continue}
  
      "password: " {send  "$pwd\r"}
  
  }
  
  
  expect "*#"
  send "ssh $usrnm@$addr2\r"
  
  expect {
  
      "(yes/no)?" {send "yes\r";exp_continue}
  
      "password:" {send  "$pwd\r"}
  
  }
  
  expect "*#"
  
  send "cd /tmp/myself/folder\r"
  
  expect "*#"
  
  send "./run_engine.sh test.py\r"
  
  expect eof
  
  #interact
  </code></pre>
  
  <p>So if I do</p>
  
  <pre><code>expect my_expect.exp
  </code></pre>
  
  <p>it just prints the command:</p>
  
  <p><code>spawn ssh aaaaaa@xxx.cloud.xxx.com -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no
  (10s later)
  ssh aaaaa@xxx.xxxx.xxxx.com
  (10s later)
  cd /tmp/amz337/COAFALV
  (10s later)
  ./run_engine.sh test.py
  (exit)
  </code></p>
  
  <p>What's wrong with my script?</p>