Skip to content

Instantly share code, notes, and snippets.

@artsi0m
Last active August 10, 2021 20:44
Show Gist options
  • Save artsi0m/51e644b9d4eff2340fef4abf0ba13656 to your computer and use it in GitHub Desktop.
Save artsi0m/51e644b9d4eff2340fef4abf0ba13656 to your computer and use it in GitHub Desktop.
Get last post from a static page
#!/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