title: Shell script to poll whether a service is up
body: <p>I wanted to know if there is any error in the code </p>
  
  <pre><code>while true
  do
      var=$(curl http://${SERVER_HOST}:8060/vmc/vdisizer/api/v1/health) &amp;&amp; echo "Got Reply from $SERVER_HOST" || echo "Curl failed to connect to $SERVER_HOST" 
      if [ "$var" -eq "OK" ]
      then
          echo "Success"
          break
      fi
  done
  </code></pre>
  
  <p>This does not work and I get the following error - </p>
  
  <pre><code>int-tester_1     | curl: (52) Empty reply from server
  </code></pre>
  
  <p>I want this to continuously poll the service till the service replies "OK" and then break from the loop.</p>
  
  <p>On changing -eq to = , I get the following error -</p>
  
  <pre><code>int-tester_1     | + var=OK
  int-tester_1     | Got Reply from 10.2.223.87
  int-tester_1     | + echo 'Got Reply from 10.2.223.87'
  int-tester_1     | + '[' = OK ']'
  int-tester_1     | ./run_itests.sh: line 33: [: =: unary operator expected
  </code></pre>