I am trying to get the status of an api call and check if it is Success or Failure based on this result api call continues. If it is Success or Failure then exit if condition and loop else continue to call the api to check status.
script :
#!/bin/sh
while true; do
status_check=sudo docker exec $ContainerID calm describe app "test_status" | grep "\"action_create" | cut -c29- | cut -d ")" -f1
echo "${status_check}"
if [ "${status_check}" == "SUCCESS" ] || [ "${status_check}" == "FAILURE" ]
then
echo "Break"
break
else
sleep 60s
$status_check
fi
done
For the above script output is : The output is already trimmed to get the specifically but still when its executed below 3 lines are streamed out. I need just the 3rd line to check the condition. It can be RUNNING or POLICY_EXEC or FAILURE or SUCCESS. It has to exit the if condition and loop only for SUCCESS or FAILURE.
[2022-12-29 19:26:34] [INFO] [calm.dsl.cli.apps:148] test_status found
[2022-12-29 19:26:34] [INFO] [calm.dsl.cli.apps:157] Fetching app details
SUCCESS