Thursday, September 24, 2009

Birthdays!!

Birthdays are the most difficult thing to remember( or may be second most difficult after names or faces :P). So people put reminders on various websites creating birthday calendars. But what if you are not allowed to access external emails? So wrote simplest of scripts to do it and sharing it here in case anyone needs it.

#!/bin/ksh

TODAY_DATE=`date +'%m%d'`

BIRTHDAY_FILE=birthday

RECIPIENTS="your mail ID"

TO_BE_MAILED=mail

NAME=`grep $TODAY_DATE birthday|awk '{FS=" "} {print $2}'`

if [[ -n $NAME ]];
then
echo "To: $RECIPIENTS">$TO_BE_MAILED
echo "Subject: Birthday Reminder" >>$TO_BE_MAILED
echo "Mime-Version: 1.0">>$TO_BE_MAILED
echo "Content-Type: text/html" >>$TO_BE_MAILED
echo "<><>">>$TO_BE_MAILED
echo "< equiv ="\" content="\" charset="UTF-8\">">>"$TO_BE_MAILED
echo "< /HEAD><>">>$TO_BE_MAILED
echo "Today is $NAME's birthday">>$TO_BE_MAILED
echo "< /BODY>< /HTML>">>$TO_BE_MAILED
`cat $TO_BE_MAILED|/usr/lib/sendmail -t `
fi

You can refine and modify it according to your needs. I just was too lazy to improve it once it started working.Add the script to your ".profile". And as soon as you login you will get an email reminding you of any birthday :). One important thing, because blogger doesnt allow me to write HTML tags i have added space before ever HTML tag, please remove that .All birthday's are saved in a file named birthday in the below format : birthday , followed by name
0101 PAPA
0202 MUMMY
0303 SIS

6 comments:

Shashi Kant Sharma said...

Awesome dude ...

Just a lil doubt:
What SMTP server will sendmail use ?

Shobhit said...

dunno :)..

There is one running on each of our machines so didnt care to think :P

vaibhavs said...

Nerd !!!
:)

Shobhit said...

bhai ab tu aisa bole ? :P

Ronny Cooper said...

Yaar, it still means ki I have to send the birthday greeting/orkut and facebook message. How abt this script directly doing the next steps along with sending me the reminder :D

Shobhit said...

hahaha..Ronny ye Beta version hai...final release might include new feature :P