Asterisk-phone-reminder/Date-fetching

Aus LaborWiki
Version vom 5. November 2010, 09:50 Uhr von Soeren (Diskussion | Beiträge) (year selection depending on date)
(Unterschied) ← Nächstältere Version | Aktuelle Version (Unterschied) | Nächstjüngere Version → (Unterschied)
Wechseln zu: Navigation, Suche

This is Part of the Asterisk-phone-reminder.

Automatically fetching dates from the remondis Website:

#!/bin/bash
YEAR=`date '+%Y'`
SRCURL='http://www.remondis.de/index.php?id=4811&streetSearch=1&cityIdent=Bochum&zip=44701&street=Alleestra%C3%9Fe'
TFILE="/tmp/${RANDOM}_zeug_das_der_muell_parser_hier_liegen_lassen_hat"
wget -O $TFILE $SRCURL
DATES=`grep -Eo '[0-9]+\.[0-9]+\.' $TFILE`
echo "==============================="
echo -e "Dates found:\n$DATES"
echo "==============================="
echo 'Hey you, human! Are the dates all right? Shall I proceed? [y/N] '
read -n 1 YN
if [ "$YN" != "Y" ] && [ "$YN" != "y" ] ; then
      exit
fi
DDIR="/tmp/$RANDOM"
mkdir $DDIR
for i in $DATES ; do
      FNAME=`echo $i | sed -r "s/[^0-9]*([0-9]+)\.([0-9]+)\..*/${YEAR}-\2-\1-gelbersack/"`
      > ${DDIR}/${FNAME}
done
echo "Files created in $DDIR. Review & then copy it to /etc/labor-task-reminder/dates"


This little script will download the appropriate Website with the dates for the trash pickup service.