Skip to content

Instantly share code, notes, and snippets.

@yanbe
Created December 7, 2010 11:05
Show Gist options
  • Save yanbe/731680 to your computer and use it in GitHub Desktop.
Save yanbe/731680 to your computer and use it in GitHub Desktop.
Check arbitrary PDF file on the web and mail diff from last version if it has changed.
#!/bin/sh
export PATH=/opt/bin:$PATH
URL=http://example.com/kushitu.pdf
CUR_LENGTH=`curl --head $URL 2>/dev/null | awk '/Content-Length:/ {print $2}'`
cd /home/john/kushitu_checker
if [ $CUR_LENGTH != `cat last_length` ]; then
curl $URL > kushitu.pdf
pdftotext -enc UTF-8 -raw kushitu.pdf /dev/stdout | sed 's/^.*現在//g' > kushitu.txt
diff -U 0 kushitu.txt last_kushitu.txt | nail -A myaccount -s "Room Updates" [email protected]
echo $CUR_LENGTH > last_length; rm kushitu.pdf; mv kushitu.txt last_kushitu.txt
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment