Skip to content

Instantly share code, notes, and snippets.

@cybermonde
Created February 19, 2015 10:57
Show Gist options
  • Save cybermonde/6fc24881302e5c80044f to your computer and use it in GitHub Desktop.
Save cybermonde/6fc24881302e5c80044f to your computer and use it in GitHub Desktop.
parse RSS file to tweet new entries
#!/bin/bash
# parse RSS file to tweet new entries
# author : http://www.cybermonde.org
# needed : feedstail (https://github.com/Psycojoker/feedstail) and ttytter (http://www.floodgap.com/software/ttytter/)
# usage (summary = description) :
# feedstail -u "http://www.domain.name/rss.php" -f "{summary}|{link}" -k summary | /home/sweethome/parserss.sh | /home/sweethome/ttytter.pl -script
# new separator
IFS="|"
# reading summary and link
while read summary link
do
# link (URL) length = ${#link}
# summary (description) length = ${#summary}
# if < 140 signs, display all
if [ $((${#link}+${#summary})) -lt 140 ]
then echo "$summary $link"
# else cut summary and add (...) before link
else
echo "${summary:0:140-${#link}-6}(...) $link"
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment