title: Why my Jenkins script hangs on while loop?
body: <p>i am running a Jenkins script for building a Jenkins program and preparing it's environment. 
  i posted the section of the script where it hangs. it hangs in the <code>while [[ "$ENDPOINT_STATUS" != 0 &amp;&amp; (( $COUNTER &lt; 5 )) ]]</code>  line. could anyone please tell me what is the problem ? </p>
  
  <pre><code>##############
  ## wait until config wizard exits
  while [ $($SSH pgrep -f /opt/company/grapevine/bin/grapevine_config_wizard | wc -l) -ne 0 ]
  do
      echo "Config wizard still running. Sleeping..."
      sleep 30
  done
  
  $SSH chmod -v 755 /home/grapevine/.python-eggs || true
  $SSH chown -vR grapevine:grapevine /home/grapevine/.python-eggs || true
  
  source $WORKSPACE/tools/dev/quick-sanity/poormans-quick-sanity.sh "$CONTROLLER_IP"
  
  set +e
  run_basic_tests "$CONTROLLER_IP"
  ENDPOINT_STATUS=$?
  set -e
  COUNTER=0
  
  while [[ "$ENDPOINT_STATUS" != 0 &amp;&amp; (( $COUNTER &lt; 5 )) ]] 
  do
      echo "At least one endpoint is not up. Sleeping..."
      sleep 60
  
      set +e
      run_basic_tests "$CONTROLLER_IP"
      ENDPOINT_STATUS=$?
      set -e
  
      (( COUNTER += 1 ))
  done
  
  if [ "$ENDPOINT_STATUS" -ne 0 ]
  then
      echo "Hard fail Failing"
      exit 1
  fi
  
  if [ $($SSH service runonce status | grep ERROR | grep config_wizard | wc -l) -gt 0 ]
  then
     echo "Config wizard failed with errors:"
     $SSH cat /var/log/runonce/config_wizard*.log
     exit 1
  else
     echo "Config wizard succeeded"
     echo "Sleeping while Grapevine services start..."
     sleep 300
     exit 0
  fi
  </code></pre>