How to send mails based on email ids residing in table?

Hello Gurus,
I have one table which consists of two field:-

PROG_NAME EMAIL
xxxx email1,email2,email3
yyyy email4,email1,email2

I want to to send mails by using mailx command.
But how do I get each and every mail ids from table against each prog_name
I have used sql query and stored the email field values at text file.

Hi,
Do you need the email IDs to be read from the text file or from the database?

From the file, it is pretty much easy. From the database, you can use SQL Plus to read the field values from the database and store it in a variable for further processing. Use this link for code samples on how to use SQL Plus in Unix.

I want the mail ids to be read from a text file.

Thanks-
P

What do you mean by

? Please explain in detail also supplying examples.

  1. Get the program name from user
  2. Assign it to a variable
  3. Search for the program name in the file(say input.txt)
grep -i $program_name input.txt
  1. Extract required information from step 3 using
cut

or

awk

commands.