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

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -