title: use expect to spawn command with arguments containing spaces
body: <p>I want to use <code>expect</code> to run a simple command <code>cat /tmp/id_rsa.pub</code> over ssh.</p>
  
  <p>In a shell, I can run this wo problem, (with manually put in the password)</p>
  
  <pre><code>ssh root@localhost 'cat /tmp/id_rsa.pub'
  </code></pre>
  
  <p>I want to automate this with <code>expect</code>. My <code>expect</code> script is,</p>
  
  <pre><code>#!/usr/bin/expect
  eval spawn ssh root@localhost 'cat /tmp/id_rsa.pub'
  expect "password:"
  send "123456"
  expect eof
  </code></pre>
  
  <p>It throws error <code>bash: cat /tmp/id_rsa.pub: no such file or directory</code>. it looks very strange to me. What could be the possible cause?</p>
  
  <p>Edit: after some testing, I find this is common, not only in the case of <code>cat</code>. If the argument to spawned command is with space (even if it's in the quotes), it will have problem. For example, replacing <code>cat /tmp/id_rsa.pub</code> with other commands with spaces, like </p>
  
  <pre><code>eval spawn ssh root@localhost 'which java'
  </code></pre>
  
  <p>it complains with <code>bash: which java: command not found</code>. But if replacing that with <code>pwd</code>, like </p>
  
  <pre><code>eval spawn ssh root@localhost 'pwd'
  </code></pre>
  
  <p>it work fine.</p>