title: while loops within expect
body: <p>I am using expect within bash. I want my script to telnet into a box, expect a prompt, send a command. If there is a different prompt now, it has to proceed or else it has to send that command again.
  My script goes like this:  </p>
  
  <pre><code>\#!bin/bash  
  //I am filling up IP and PORT1 here  
  expect -c "    
  set timeout -1  
  spawn telnet $IP $PORT1  
  sleep 1  
  send \"\r\"  
  send \"\r\"  
  set temp 1  
  while( $temp == 1){    
  expect {  
  Prompt1 { send \"command\" }  
  Prompt2 {send \"Yes\"; set done 0}  
  }  
  }  
  "  
  </code></pre>
  
  <p>Output:  </p>
  
  <pre><code>invalid command name "while("  
      while executing  
  "while( == 1){" 
  </code></pre>
  
  <p>Kindly help me.<br>
  I tried to change it to  <code>while [ $temp == 1] {</code> </p>
  
  <p>I am still facing the error below:  </p>
  
  <p>Output:  </p>
  
  <pre><code>invalid command name "=="  
      while executing  
  "== 1"  
      invoked from within  
  "while [  == 1] {  
  expect {
  </code></pre>