#!/bin/ksh data_file="/home/oracle/data" email_file="/home/oracle/birthday.email" today_month=`date +%m` today_day=`date +%d` today_date="$today_month,$today_day" before_15_days="$today_day-15" all_friends="$(grep -v '^#' $data_file | grep $today_date)" for friend in $all_friends do email_addr=$(echo $friend | cut -d , -f 5) if [ -z $email_addr ]; then continue fi first_name=$(echo $friend | cut -d , -f 1) last_name=$(echo $friend | cut -d , -f 2) full_name="$first_name $last_name" echo "$full_name" "$email_addr" sed "s/_:/$full_name/g" $email_file | mailx -s "Happy birthday : $full_name" -c "shadab@whitehatagency.com.au" $email_addr done exit 0
Create a file called data with the data entry for birth date, name and email address
John,Doe,01,05,john.doe@company.com Mary,Bright,09,28,mary.bright@company.com William,Smith,05,14,william.smith@company.com
Create a file birthday.email with template for ascii text to be send.
Dear _: ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~* ~*~* ~*~* WHITEHAT AGENCY WISHES YOU MANY HAPPY RETURNS FOR THE DAY ~*~* ~*~* HOPE YOU HAVE A JOYOUS, SUCCESSFUL & HEALTHY YEAR AHEAD OF YOU !! ~*~* ~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~*~* ,-. | | | "--. ,--.-.,-.--. ,-.--. ,-. ,-. | ,-. \/ ,-. || ,-. \| ,-. \| | | | | | | |\ `-' || `-' /| `-' /| `-' | `-' `-' `--'-'| .--' | .--' `--. | | | | | | | `-' `-' `-' ,-. _ ,-. ,-. ,-. | | (_) | |_ | | | | | "--. ,-.,-.--.| _)| "--. ,--" | ,--.-.,-. ,-. | ,-. \| || ,-./| | | ,-. \/ ,-. |/ ,-. || | | | | `-' /| || | | | | | | |\ `-' |\ `-' || `-' | "-'--' `-'`-' `-' `-' `-' `--'-' `--'-' `--. | | | Best Regards, Team Whitehat