title: Expect script for remote SSH login and executing commands
body: <p>I am using the following Expect script for remote SSH login to a Raspberry Pi and am executing the commands:</p>
  <pre><code>#!/usr/bin/expect
  set timeout 60
  spawn ssh [lindex $argv 1]@[lindex $argv 0]
  expect &quot;yes/no&quot; {
      send &quot;yes\r&quot;
      expect &quot;*?assword&quot; { send &quot;[lindex $argv 2]\r&quot; }
      } &quot;*?assword&quot; { send &quot;[lindex $argv 2]\r&quot; }
  expect &quot;pi@raspberrypi ~ $ &quot; {
      send &quot;ls -la\r&quot;
      }
  interact
  </code></pre>
  <p>The problem is that this script is able to log in into the Raspberry Pi, but when it comes to the line for executing the &quot;ls -la&quot; command, nothing happens. How can I fix this script? Where am I making the mistake?</p>
  <p>OK, if I put the</p>
  <blockquote>
  <p>exp_internal 1</p>
  </blockquote>
  <p>line in my script, I get the following output in the where matching fails:</p>
  <blockquote>
  <p>expect: does &quot;: \r\nLinux raspberrypi 3.10.24+ #614 PREEMPT Thu Dec 19 20:38:42 GMT 2013 armv6l\r\n\r\nThe programs included with the Debian GNU/Linux system are free software;\r\nthe exact distribution terms for each program are described in the\r\nindividual files in /usr/share/doc/*/copyright.\r\n\r\nDebian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent\r\npermitted by applicable law.\r\nLast login: Mon Mar  3 19:00:11 2014 from 192.168.1.200\r\r\n\u001b]0;pi@raspberrypi: ~\u0007\u001b[01;32mpi@raspberrypi\u001b[00m \u001b[01;34m~ $\u001b[00m &quot; (spawn_id exp6) match glob pattern &quot;*pi@raspberrypi ~ $*&quot;? no</p>
  </blockquote>
  <p>Shouldn't this matching be true?</p>