title: How to make expect command in expect program script to wait for exact string matching
body: <p>I want to know how to make expect command in expect script to wait for exact string to be matched before proceeding to next line in the script.</p>
  
  <p><strong>Bourne shell (sh) script:</strong></p>
  
  <pre><code>#!/bin/sh
  #!/usr/bin/expect
  
  spawn ssh -Y localuser@lbblr-tirumala
  expect -exact "localuser@lbblr-tirumala's password: "
  
  # replace password with ur own passwd
  send "geomax45\r"
  
  # replace the prompt with ur own prompt
  expect "localuser@lbblr-tirumala:~$ "
  
  # run application
  send "./sample\r"
  
  expect "*Menu*\r
  1. print hello world\r
  2. print Bye world\r
  3. quit\r
  enter choice: "
  # enter choice 1
  send "1\r"
  expect "Bye world\r
  *Menu*\r
  1. print hello world\r
  2. print Bye world\r
  3. quit\r
  enter choice: $"
  # enter choice 2
  send "2\r"
  </code></pre>
  
  <p>In the above code after entering 1 the code should wait for "Bye world\r......" string to occur on the screen. But even though the screen prompts different string altogether, the code is executing the next line and entering option 2, which should not occur as per definition of expect. It should wait until the complete string in expect command matches.</p>
  
  <p>I want to know whether there is any stricter command that can be used so that expect waits until exact string matching occurs. Please help me in this issue</p>