A simple reminder system by mail:
Think about how often you forgot mother's/father's/sister's birthday or your wedding day.
Just set the var accountname to your email account of your asus
Save the script to /opt/bin/reminder and set the rights:
Code:
#! /bin/sh
#Mail a reminder to any recipient with esmtp
#written by newbiefan 2011 for user of asus routers
#contact: hirau@gmx.at
#Please read the entire howto in order to understand everything
#use name of your file, usually reminder.txt - you can store the file anywhere
bfname=/opt/etc/reminder.txt
accountname="youremail@yourprovider.com"
#use your loglocation, usually logs are stored in /opt/var/log
loglocation=/opt/var/log/reminder.log
#if you do not need any log-file, uncomment
#loglocation=/dev/null
#we count all lines
countlines=`/opt/bin/wc -l $bfname | /opt/bin/cut -d " " -f1`
today_long=$(/opt/bin/date +"%d.%m.%Y")
today=$(/opt/bin/date +"%d.%m")
#lets start with line 1
i=0
while [ $i -ne $countlines ] ; do #start the loop over each line
let i=$i+1
#grab data from file
born=`/usr/bin/head -n$i $bfname|/usr/bin/tail -n1|/opt/bin/cut --delimiter=: -f1`
reminddate=`/usr/bin/head -n$i $bfname|/usr/bin/tail -n1|/opt/bin/cut --delimiter=: -f2`
recipient=`/usr/bin/head -n$i $bfname|/usr/bin/tail -n1|/opt/bin/cut --delimiter=: -f3`
subject=`/usr/bin/head -n$i $bfname|/usr/bin/tail -n1|/opt/bin/cut --delimiter=: -f4`
text_to_send=`/usr/bin/head -n$i $bfname|/usr/bin/tail -n1|/opt/bin/cut --delimiter=: -f5`
if [ "$today" = "$reminddate" ] ; then #yes, create the email
echo "date: $today_long" > /tmp/remindmail
echo "to: $recipient" >> /tmp/remindmail
echo "subject: $subject" >> /tmp/remindmail
echo "from: $accountname" >> /tmp/remindmail
echo >> /tmp/remindmail
echo "AUTOMAILER: REMINDER FOR DATE $born" >> /tmp/remindmail
echo $text_to_send >> /tmp/remindmail
echo "Email is automatically generated, please do not answer!" >> /tmp/remindmail
/opt/bin/esmtp -t < /tmp/remindmail # send email
onlytime=`date +"%T"`
echo "Reminder sent $today_long at $onlytime to $recipient with subject: $subject" >> $loglocation
fi
done #end of lines in file
set the rights with chmod 755 /opt/bin/reminder
Further you need a textfile with the data.
Make a file reminder.txt and add your entries. The syntax of a line is following:
date_to_remind:when_to_remind:recipients_email:you rsubject:Text_to send
Consider always to make no spaces and to use as delimiter a : (colon)
The format of date_to_remind must be: dd.mm.yyyy
The format of when_to_remind must be: dd.mm
Recipients email must be a valid email address
Your subject can be any short text
Text_to_send can be any text (should not be too long)
Just add your lines (as much as you want) to you file reminder.txt
Store your reminder.txt to /opt/etc/reminder.txt
Code:
touch /opt/etc/reminder.txt
vi /opt/etc/reminder.txt #goto insert mode
31.03.1960:28.03:hirau@gmx.at:Birthday reminder:Please remember Helmut's birthday
28.06.1936:05.06:hirau@gmx.at:Birthday reminder:Attention, Mama's birthday is coming soon!
28.06.1936:24.06:hirau@gmx.at:Second birthday reminder:Attention, Mama's birthday in 4 days!
28.06.1936:24.06:sistersaccount@gmx.at:Birthday reminder:Attention, Mama's birthday in 4 days!
#save the file
Now only one thing remains, add to your crontab: (If you are not root, use admin instead)
Code:
0 1 * * * root /opt/bin/reminder
No worry any more to forget anything important!
If any problem occurs when using cron, just use the full path of each command (e.g.: /usr/bin/head a.s.o.)
Thats it - have fun.
EDIT:In order to save your valuable time, I've added the full path to some command, hence it will work propper with cron