The UNIX and Linux Forums  


Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
how to forward mail in /var/mail/username to external mail unitipon SUN Solaris 2 05-27-2008 01:20 AM
Celebrate GnuPG's 10th birthday! iBot UNIX and Linux RSS News 0 01-12-2008 04:10 PM
Mail Script need Help??? gkrishnag UNIX for Dummies Questions & Answers 2 09-26-2006 01:32 AM
Happy birthday Linux mib News, Links, Events and Announcements 1 06-30-2005 06:21 AM
I need a script that script extract info from mail meravd Shell Programming and Scripting 1 10-19-2004 12:15 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-13-2008
Kumarsharad Kumarsharad is offline
Registered User
  
 

Join Date: Jul 2007
Posts: 2
Birthday Mail Script

Dear Friends

I want to, auto send mail to users on there Birthdate, using following script but while executing getting following error pls. suggest me for the same.


Script :-

#!/bin/sh
data_file="/var/SCRIPTS/Birthday/data"
email_file="/var/SCRIPTS/Birthday/birthday.email"
today_month=`date +%m`
today_day=`date +%d`
today_date="$today_month,$today_day"
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"
sed "s/__FULLNAME__/$full_name/g"$email_file | \
echo "mail -s "Happy birthday to you.." $email_addr"
done
exit 0

Error O/p :-

: command not founde 1: mailadmin@xyz.com
: command not founde 1: sysadmin@xyz.com



Data file :-

First Name, Last Name, Month, Date, Mail ID

XYZ,x,06,13,mailadmin@xyz.com
ABC,S,07,13,sysadmin@xyz.com
PQRj,sh,2,12,PQR@gmail.com

Email File :-

Dear __FULLNAME__:

Happy Birthday To You.

Best Regards,
XYZ
  #2 (permalink)  
Old 06-13-2008
joeyg's Avatar
joeyg joeyg is offline Forum Staff  
modérateur
  
 

Join Date: Dec 2007
Location: Home of 17-time world champion Boston Celtics
Posts: 1,311
Wink eliminate the ` (ticks) around one of your commands

This command:
email_addr=`$(echo $friend | cut -d , -f 5)`
should be
email_addr=$(echo $friend | cut -d , -f 5)

[At least, I had an error when evaluating that command.]

I also eliminated " around a couple of other commands, resulting in following:


Code:
data_file="bdata"
#email_file="/var/SCRIPTS/Birthday/birthday.email"
today_month=`date +%m`
today_day=`date +%d`
today_date="$today_month,$today_day"
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/__FULLNAME__/$full_name/g"$email_file | \
#   echo "mail -s "Happy birthday to you.." $email_addr"
done
exit 0


Code:
> chk_bd 
XYZ x mailadmin@xyz.com

and, that looks correct for the input file.
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 09:32 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0