Shift reminder system

Hi,
Help me with a script which can read shift related data(in .csv file) and send a mail to the user reminding them about the shift.. Already there is a table with empid,name,mailid) need to use this table for this task

what is shift related data ?

give the input csv file and the output expected

input file looks like this
Date Shift1_name Shift2_name Shift3_name
16/6/11 raja ramu somu
.....

i want a script that could read the name and send a mail on a daily basis(mailid if raja is stored in a table) ., telling him about the shift...

what table ?

what you have tried so far ?

i have created a table with the fields,
empid name mailid
1 raja raja@xy.com
and entered the values of all persons who are in that file...

Now i want a script that could fetch the data in (input file .csv file) and compare it with the above table to send a mail to specific persons reg their shifts

So , you want a script which runs and checks only the "Date" part from the file and mail to the user . ( the sample mail something like this : Raja -> Shift1 ) ?

Hi Panyam.,
Ya, u r partly right ., validation needs to be done not only for "Date" part but also for the "name" part since there can be more than one person in a shift.. so there should be some scenario wherin u can get the name and compute their EMPID and by using that u can send a mail to a particular user!!!

Here is the template:

 
today=`date "+%d/%0m/%y"`
 
grep "$today" input_csv  2>/dev/null 1>2&
if [ $? -ne 0 ]; then
echo "no user"
else
grep "$today" input_csv   | while read line 
do
i=get names one by one
e=`sqlplus -s "username/passwd" << EOF
set head off
set echo off
select mailid from user_table where name = "$i";
EOF
`
Check if the name exists by checking whether e is null or not
if e is not null then
mail -s specifi user mail id (stored in e)
done
fi

Thanks for the template but my scenario is that validation needs to be done not only for "Date" part but also for the "name" part since there can be more than one person in a shift.. so there should be some scenario wherin u can get the name and compute their EMPID ..

Hi ,
I am in the last part of this ., can anyone please help me how to send a mail to the group of mail ids got in the variable 'e'...
mail -s "Hello" e., is it right????

 
mail -s "Hello" $e

Hi .,
I m struck here., cud u plz help...
I have changed some logic in this system., I have loaded my .csv file in another table and now comparing the two tables and fetching the mail id in the variable "e"
The code i used to send mail is

e=`sqlplus -s "username/pwd@DB" << EOF
select user_table.MAILID from user_table inner join onshore on user_table.RESOURCE_NAME = onshore.MHC;
EOF`
mailx -s "You are in shift today" $e

where onshore is the table made from .csv file.,

i m unable to send the mail., when i execute the script it stands till timeout and gets closed without sending mail...
Thanks in advance...

---------- Post updated 07-08-11 at 11:01 AM ---------- Previous update was 07-07-11 at 06:10 PM ----------

Hi .,
When i execute

e=`sqlplus -s "username/pwd@DB" << EOF
select user_table.MAILID from user_table inner join onshore on user_table.RESOURCE_NAME = onshore.MHC;
EOF`
alone., i could view the result wen i give echo $e.,

MAILID -------------------------------------------------- ram@abc.com hari@abc.com raj@abc.com MAILID -------------------------------------------------- ram@abc.com hari@abc.com raj@abc.com., but there are only 3 rows in the database.. why i am getting duplicate here???

And also i couldnt send mail using this
mailx -s "You are in shift today" $e., wen i execute i get "mail: illegal option -- ----" error ., Where i went wrong...!!????