title: Wait for prompt in expect script
body: <p>I need an <code>expect</code> script to wait for an issued command to finish, and then log out from <code>telnet</code>. Here is the script:</p>
  
  <pre><code>spawn telnet host
  send "username\r"
  send "password\r"
  sleep 3
  send "custom_command\r"
  while {???}
  {
      sleep 1
  }
  send "logout\r"
  expect eof
  </code></pre>
  
  <p>The part that I don't know how to phrase is <code>???</code>. I basically just need to wait for the <code>prompt</code> to show up, and as soon as it shows up, the script should end. I'm guessing it should be something like <code>[gets line != "prompt&gt;" ]</code>.</p>