I´m using to wait until a service is up and runnig, but using curl after the first attemp to connect and fail the whole script exit. How can avoid the exit after the fail of the curl?. I´ve tried using --fail on curl but nothing.
Here my code
#!/bin/bash
getX(){
echo `curl --fail domain.com` --> should return an array
}
test(){
result=`getX`
while [ ${#result[@]} -eq 0 ]
do
echo "waiting"
result=`getX`
done
}
test
My suggestion would be not to use the output, but the return code of curl, how about that?
getX(){
result=`curl --fail domain.com` --> should return an array
rc=$?
}
test(){
getX
while [ $rc -ne 0 ]
do
echo "waiting"
getX
done
}
test
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With