shell - CURL: how to run a single curl command 3 times if it fails with error and condition is not met? -
i'm running curl command inside loop, want if curl command fails, should re-run loop including curl command 3 times .what should right approach of doing that?
while [[ "$environment" == "dev" ]]; curl command done
you can write separate function below , use:
#!/bin/sh count=0 execute_curl () { count=`expr $count + 1` curl command if [ $? -ne 0 ] && [ $count -lt 3 ] execute_curl else return $? fi } while [[ "$environment" == "dev" ]]; execute_curl done
Comments
Post a Comment