Difference between revisions of "Curl bash script"

From UVOO Tech Wiki
Jump to navigation Jump to search
(Created page with "#!/bin/bash set -eu mcode=200 url="https://example.com" while true; do ts=$(date "+%Y%m%dT%H%M%S") rcode=$(curl -X GET -sI "$url" | awk '/^HTTP/{print $2}') if [ "$rco...")
(No difference)

Revision as of 00:37, 26 September 2023

!/bin/bash

set -eu

mcode=200 url="https://example.com"

while true; do

 ts=$(date "+%Y%m%dT%H%M%S")
 rcode=$(curl -X GET -sI "$url" | awk '/^HTTP/{print $2}')
 if [ "$rcode" != "$mcode" ]; then
   echo "ERROR: Invalid code. Was $rcode expected $mcode. TS: $ts"
 fi
 sleep 5

done