I have the following script in place:
while [[ $(curl test.com/test) != "true" ]];
do
if [[ $(curl test.com/test) == "stopping" ]] ;then
/etc/shutdown.sh # this script will change the output of $(curl test.com/test) to "true"
else
sleep $sleep_timer
fi
done
In this script, I run $(curl test.com/test) twice, once in the while loop, and once in the if statement.
I don't need to run it twice for the script to work, and I would like to avoid it to reduce the running time, so I'm looking for a way to save the output of the first $(curl test.com/test) as a variable, something in the lines of:
while [[ $(curl_output=$(curl test.com/test)) != "true" ]];
do
if [[ $curl_output == "stopping" ]] ;then
/etc/shutdown.sh # this script will change the output of $(curl test.com/test) to "true"
else
sleep $sleep_timer
fi
done
But I'm not sure if it's possible...