The intention of the following code is to check status of JBoss, the while loop iterates until the JBoss status comes to the 'DOWN' state. ` I have the following script, which I've set to this environment variable so that I can make use of it, vs the actual path to the script:
$ JBOSS_ROOT=/opt/app/jboss/jboss.sh
time=1
while  [ $JBOSS_ROOT status | egrep -nq "DOWN"  ]
  do
        echo "JBoss stooping, please wait ......."
        sleep 1m
        if [ $time -gt 6 ]
         then
            echo "Something went wrong.. it's been running more than 5 \
                minutes, please check JBoos server log and deployments"
            exit
        fi
        time=$(expr "$time" + 1)
  done
echo "JBoss stopped"
`
- $JBOSS_ROOT statusreturns "JBoss DOWN" if JBoss in down (stop position).
- $JBOSS_ROOT statusreturns "JBoss (pid:32627) is RUNNING" if JBoss is in running (start position).
Throwing error at while loop. saying that ./stop.sh: line 5: [: missing]'`.

