I am using the bash script wait for it to check if a container is up and running before I launch another container.
https://github.com/vishnubob/wait-for-it
It seems that if it's successful it returns 0 and if not 124. Is it possible to check this value and if it's not successful exit the script?
I've tried
./wait-for-it.sh $BROKER_ADDRESS echo $? if ($?==124) then echo "exiting as broker service never became available" exit fi And I can see it echos 124 in my terminal but then the check fails and it carries on launching the container. I'm assuming my conditional check is wrong but I can't seem to figure out why
$?right after the call towait-for-it.shin a variable and use it. Otherwise,$?could be different - it represents the last command's exit status.if [[ $? -eq 124 ]]; thenecho,$?is 0 because theechosucceeded. Usestatus=$?and then check$status, etc. Or test$?without echoing it, but capturing it gives you more flexibility.(($? == 124)), by the way. Otherwise, you're trying to run$?==124as a command in a subshell.