Skip to content

Instantly share code, notes, and snippets.

@GammaGames
Created March 7, 2024 16:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save GammaGames/0655945874a6df3450806ef93ead9886 to your computer and use it in GitHub Desktop.
Save GammaGames/0655945874a6df3450806ef93ead9886 to your computer and use it in GitHub Desktop.
purl - curl endpoint and print non-200 statuses (ping + curl)
#!/usr/bin/env bash
_val=`curl -Isk $2 | grep HTTP | cut -d ' ' -f2`
echo "$(date) $_val"
_diff=0
while :
do
_val2=`curl -Isk $2 | grep HTTP | cut -d ' ' -f2`
if [ "$_val" != "$_val2" ]; then
echo "$(date) $_val2"
_diff=1
else if [ $_diff -eq 1 ]; then
echo "$(date) $_val2"
_diff=0
fi
fi
sleep $1
done
@GammaGames
Copy link
Author

Usage: ./purl.sh 1 https://www.google.com/

Sample output:

Thu Mar  7 09:49:19 AM MST 2024    200
Thu Mar  7 09:53:09 AM MST 2024    502
Thu Mar  7 09:53:10 AM MST 2024    502
Thu Mar  7 09:53:11 AM MST 2024    502
Thu Mar  7 09:53:12 AM MST 2024    502
Thu Mar  7 09:53:13 AM MST 2024    502
Thu Mar  7 09:53:15 AM MST 2024    200

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment