From 83dabfb470d5ec4726986d4f06f14720b5008591 Mon Sep 17 00:00:00 2001 From: Tobias Diez Date: Sat, 17 Sep 2022 14:35:52 +0200 Subject: [PATCH] Fix checking for other status codes --- main.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/main.sh b/main.sh index 4551c99..97946ca 100755 --- a/main.sh +++ b/main.sh @@ -12,6 +12,7 @@ while test $# -gt 0; do echo "--url=URL url to poll" echo "--interval=INTERVAL Interval between each call, in seconds" echo "--timeout=TIMEOUT Timeout before stop polling, in seconds" + echo "--code=CODE status code to check" exit 0 ;; --url*) @@ -49,7 +50,7 @@ function poll_status { fi; STATUS_CODE=`curl -A "Web Check" -sL --connect-timeout 3 -w "%{http_code}\n" $auth $url -o /dev/null` echo "$(date +%H:%M:%S): The status code is $STATUS_CODE"; - if [[ "$STATUS_CODE" == "200" ]]; then + if [[ "$STATUS_CODE" == "$code" ]]; then echo "success"; exit 0; break; @@ -58,5 +59,5 @@ function poll_status { done } -printf "\nPolling '${url%\?*}' every $interval seconds, until status is '200'\n" +printf "\nPolling '${url%\?*}' every $interval seconds, until status is '$code'\n" poll_status