title: Expect script execution status
body: <p>In the following expect script how to  get the exit status of rsync in the expect script
  <code>if [$? -eq 0]</code>  throws an error as </p>
  
  <pre><code>         invalid command name "$?"
           while executing
           "$? -eq 0 "
           invoked from within
          "if [ $? -eq 0 ]"
         (file "./tmp544.sh" line 7)
  
  
      #!/usr/bin/expect -f
  
      eval spawn ssh -l root 174.54.87.12 rsync /root/project /usr/project
      expect "root@174.54.87.12's password: $"
      send "\xxxxxxx\n"
      expect "\\$ $"
      if [ $? -eq 0 ]
      then
        echo "11"
      else
        echo "22"
      fi
  </code></pre>