Last active
August 10, 2021 20:44
-
-
Save artsi0m/51e644b9d4eff2340fef4abf0ba13656 to your computer and use it in GitHub Desktop.
Get last post from a static page
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env sh | |
set -e | |
Url=$1 | |
Sleep_Arg=$2 | |
[ -z "$Sleep_Arg" ] && Sleep_Arg=60 | |
get_http_header_last_modified () { | |
curl "$1" --output /dev/null --silent --dump-header - \ | |
| grep Last-Modified | |
} | |
notify_mail() { | |
[ "$1" != "$2" ] \ | |
&& printf 'Page on address %s updated' "$3" \ | |
| mail -s 'Page updated' "$USER" | |
} | |
while true; | |
do | |
Last_Modified_First="$(get_http_header_last_modified "$Url")"; | |
sleep $Sleep_Arg | |
Last_Modified_Second="$(get_http_header_last_modified "$Url")"; | |
notify_mail "$Last_Modified_First" "$Last_Modified_Second" "$Url" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment