Curl bash script
Jump to navigation
Jump to search
Test return code
#!/bin/bash set -eu expected_rcode=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" != "$expected_rcode" ]; then echo "ERROR: Invalid code. Was $rcode expected $expected_rcode. TS: $ts" fi sleep 5 done