I created this bash script and can't seem to figure out why my code inside of the if block isn't executing.
db_instances_status="creating"
db_instances_status=$(makes api request to get value)
COUNTER=0
while [ $COUNTER -lt 1 ]; do
db_instances_status=$(makes api request to get value)
echo "$db_instances_status" # echos available
if [ "available" = "$db_instances_status" ]; then
# code never makes it here
dosomething()
break;
fi
sleep 30
done
I followed examples from this How to compare strings in Bash
and here https://tecadmin.net/tutorial/bash/examples/check-if-two-strings-are-equal/
ifstatement that saysdb_instances_status='available'. Now does your code enter theifsection? If it does thendb_instances_statusdoes NOT just containavailablein your surrounding code.echo "X${db_instances_status}X"in case the status has leading/trailing spaces.