BASH 41
Curl-test.sh By allan on 21st September 2026 11:43:07 AM
  1. #!/bin/bash
  2.  
  3. location=(B0 CVF OOV openlayers TRA VM WH1 rest)
  4. base_url="https://geocloudtest.vd.dk/"
  5. log_file="/tmp/curl-test.log"
  6. failures=()
  7.  
  8. log() {
  9.   echo "$(date '+%Y-%m-%d %H:%M:%S') $*" | tee -a "$log_file"
  10. }
  11.  
  12. log "Start"
  13.  
  14. for i in "${location[@]}"
  15. do
  16.   url="${base_url}${i}"
  17.   log "Trying $url"
  18.   res=$(curl -sS -o /dev/null -w "%{http_code}" -- "$url")
  19.   log "HTTP status code: $res for $url"
  20.  
  21.   if [[ "$res" != "200" && "$res" != "401" && "$res" != "403" ]]; then
  22.     failures+=("$i -> $res")
  23.   fi
  24. done
  25.  
  26. if (( ${#failures[@]} > 0 )); then
  27.   log "Summary: ${#failures[@]} non-200/401/403 status code(s) found"
  28.   for item in "${failures[@]}"; do
  29.     log "Failure: $item"
  30.   done
  31. else
  32.   log "Summary: all checks returned HTTP 200, 401, or 403"
  33. fi
  34.  
  35. log "Done"

Paste is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.