I have a small bash script to do some AWS CLI stuff. I am having issues with line 18 as I need to compare function1 =! (function2 && string)
specifically
if [ "$(state)" ] != [ "$(task_name)" && "RUNNING" ]
see below;
#!/bin/bash
region="eu-west-1"
cluster="mis-core-dev"
## Get task name, state and check against "RUNNING"
task_name () {
aws ecs describe-tasks --region ${region} --cluster ${cluster} --tasks "$task" --query 'tasks[].containers[].name' --output text
}
state () {
aws ecs describe-tasks --region ${region} --cluster ${cluster} --tasks "$task" --query 'tasks[].containers[].[name, lastStatus]' --output text
}
## Get Task names from Cluster
task_status () {
mapfile -t tasksInCluster < <(aws ecs list-tasks --region ${region} --cluster ${cluster} | jq -r '.taskArns[]')
for task in "${tasksInCluster[@]}"; do
if [ "$(state)" ] != [ "$(task_name)" && "RUNNING" ]
then
echo "$(task_name)" "NOT RUNNING!"
exit 1
else
state
fi
done
}
task_status
I am trying to aviod using jq
as I want to keep dependencies to a minimum