# # CONFIGURATION # # Interval between two consecutive posts SLEEP_INTERVAL=3h # File containing the toots to post DATA_FILE=megafono.txt # # CONFIGURATION END # extract_image() { sed -n -e 's/.*\(.*\)<\/img>.*/\1/p' <<< $1 } extract_text() { sed -e "s/\(.*\).*<\/img>\(.*\)/\1\2/g" <<< $1 } while : do # Last line should be empty, so we dont need an additional read here # after the while loop while read line do text=`extract_text "$line"` image=`extract_image "$line"` echo "[$(date)][INFO] Now tooting: $text" if [ "$image" != "" ] then echo "[$(date)][INFO] with image: $image" ./toot.sh -i=images/$image $text >/dev/null 2>&1 & else ./toot.sh $text >/dev/null 2>&1 & fi sleep ${SLEEP_INTERVAL} done < ${DATA_FILE} done