Mailx, Table, Multiple Email script

Hello,

I am able to write some simple scripts in linux but this time it seems a little bit hard for me.

Objective: Script will read Database.txt file and will submit separate emails to multiple persons.

Database.txt

Elvis-Presley user_ssh1 ##20140403 firstperson@gmail.com
Julia-Roberts user_ssh2 ##20140403 secondperson@gmail.com
J-Lopez user_ssh3 ##20140403 thirdperson@gmail.com

In above database.txt file, you see the name of each user_ssh* account owner.
I need to send them seperate emails.

For example:

First email to firstperson@gmail.com:

Hello Elvis-Presley,
Your ssh account user_ssh1 will be expired on 2014.04.03

Fyi
Baris35,

Second email to secondperson@gmail.com:

Hello Julia-Roberts,
Your ssh account user_ssh2 will be expired on 2014.04.03

Fyi
Baris35,

Third email to thirdperson@gmail.com:

Hello J-Lopez,
Your ssh account user_ssh3 will be expired on 2014.04.03

Fyi
Baris35,

Thanks in advance
Boris

Here's something to start with:

while read -r COL1 COL2 COL3 COL4
do
        echo "Col1 is $COL1, col2 is $COL2, col3 is $COL3"
done < inputfile
1 Like

The fielded line-record input suggests "while read a b c d do ... done', with some substringing to get the date bits (the ksh/bash flavor ${c#????????} works but needs temp variable and second cut for month). Once you have the date divided, it is just something like 'echo "..."|mailx -s ... $d'.

1 Like

Thanks,
Sorted by means of your valuable support now..

Regards
Boris

1 Like