Skip to content

Instantly share code, notes, and snippets.

@girishso
Created January 11, 2016 06:54
Show Gist options
  • Save girishso/f4ca4507abe0d7bba28c to your computer and use it in GitHub Desktop.
Save girishso/f4ca4507abe0d7bba28c to your computer and use it in GitHub Desktop.
Little script that runs every morning on my raspberry pi and emails me the movies page from esakal!
#!/bin/bash
link="http://epaper3.esakal.com/%s/Enlarge/PuneCity/Pune1Today/page%s.htm"
html_file7="/var/log/esakal.htm7"
html_file8="/var/log/esakal.htm8"
url=""
# cf. "Editing files with the ed text editor from scripts.",
# http://wiki.bash-hackers.org/doku.php?id=howto:edit-ed
prepend() {
printf '%s\n' H 1i "${1}" . wq | ed -s "${2}"
}
download() {
url=""
printf -v url $link `date +%-d%b%Y` "${1}"
echo $url
wget -O "${2}" -k $url
}
download 8 $html_file8
download 7 $html_file7
echo "appending files $html_file7 and 8"
cat $html_file7 >> $html_file8
prepend $url $html_file8
mail -a "Content-type: text/html" -s "eSakal - movies" girish.sonawane@gmail.com < $html_file8
rm $html_file8
rm $html_file7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment