Difference between revisions of "Curl bash script"
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...") |
|||
Line 1: | Line 1: | ||
+ | ## Test return code | ||
+ | ``` | ||
#!/bin/bash | #!/bin/bash | ||
set -eu | set -eu | ||
Line 4: | Line 6: | ||
mcode=200 | mcode=200 | ||
url="https://example.com" | url="https://example.com" | ||
+ | |||
while true; do | while true; do | ||
Line 13: | Line 16: | ||
sleep 5 | sleep 5 | ||
done | done | ||
+ | ``` |
Revision as of 00:37, 26 September 2023
Test return code
#!/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