title: "invalid command name" in expect script
body: <p>I have the following code for listening at a serial port:</p>
  
  <pre><code>set timeout -1
  log_user 0
  
  set port [lindex $argv 0]
  
  spawn /usr/bin/cu -l $port
  
  proc receive { str } {
    set timeout 5
    expect
    {
      timeout { send_user "\nDone\n"; }
    }
    set timeout -1
  }
  
  expect {
    "XXXXXX\r" { receive $expect_out(0,string); exp_continue; }
  }
  </code></pre>
  
  <p>Why does this give a </p>
  
  <blockquote>
    <p>invalid command name "</p>
  </blockquote>
  
  <p>error after the 5 second timeout elapses in the procedure? Are the nested expects OK?</p>