Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # LPnewswire draft, Albert Schaferle 2014-10-04
- feedURI="http://feeds.reuters.com/Reuters/worldNews"
- TMPt0=/tmp/LPnewswire.t0
- TMPt1=/tmp/LPnewswire.t1
- TMPdelta=/tmp/LPnewswire.delta
- NLOG=~/LPnewswire/lpnlog
- touch $TMPt0
- curl --silent $feedURI | xml2 > $TMPt1
- feedNAME=$(cat $TMPt1 | grep "^/rss/channel/title" | cut -d\= -f2)
- echo -n "Started reading from "$feedNAME" on " | tee -a $NLOG
- date -R | tee -a $NLOG
- echo "Priting new headlines from "$feedNAME" - press CTRL + C to exit"
- while true
- do
- curl --silent $feedURI | xml2 > $TMPt1
- diff --ignore-blank-lines -b --ignore-case --old-line-format='' \
- --new-line-format='%L' --unchanged-line-format='' \
- $TMPt0 $TMPt1 > $TMPdelta
- if [[ -s $TMPdelta ]] ; then # is delta non-empty?
- NTIME=$(date -R)
- NNEWL=$(cat $TMPdelta | wc -l)
- echo "Found "$NNEWL" new lines @ "$NTIME | tee -a $NLOG
- cat $TMPdelta | # bold title, normal description, rh-justified pubDate, all NLQ
- grep "^/rss/channel/item/title\|^/rss/channel/item/description\|^/rss/channel/item/pubDate" |
- sed '/title=/ s/$/ \\e\\x46/' |
- sed 's,/rss/channel/item/title=,\\e\\x78\\x01\\e\\x61\\x00\\e\\x45\\e\\x47\n,' |
- sed 's,/rss/channel/item/description=,,' |
- sed 's,/rss/channel/item/pubDate=,\\e\\x46\\e\\x61\\x02,' |
- cut -d\< -f1 |
- sed '/^$/d' |
- iconv -f UTF-8 -t IBM437 |
- xargs --null echo -ne |
- fold -sw 80 |
- lpr -P lpt-raw
- cp $TMPt1 $TMPt0 # I'm copying to cover up against curl giving blank output
- else echo "."
- fi ;
- sleep 1m
- done
- echo "LPnewswire on "$feedNAME" exiting."
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement