SendEmail - Script reading database file with sleep command


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting SendEmail - Script reading database file with sleep command
# 1  
Old 06-08-2013
SendEmail - Script reading database file with sleep command

Hello,
I would like to send email message to my mail list.
I have been running linux based server and I submitted this process manually up to now.
I would like to send each individual with a shell script.

In ssh panel, I tested below command and it works smoothly.

Code:
sendEmail -t member1@hotmail.com -f myemail@mail.com -u Hello There! < /var/log/body.txt

I created all ssh lines for each member and put them into a ssh file, then run the script. Here it is:

sendmail.sh
Code:
#!/bin/bash
sendEmail -t member1@hotmail.com -f myemail@mail.com -u Hello There! < /var/log/body.txt &
sleep 5
sendEmail -t member2@hotmail.com -f myemail@mail.com -u Hello There! < /var/log/body.txt &
sleep 5
sendEmail -t member3@hotmail.com -f myemail@mail.com -u Hello There! < /var/log/body.txt &
sleep 5
sendEmail -t member4@hotmail.com -f myemail@mail.com -u Hello There! < /var/log/body.txt &
sleep 5
exit 0

If I do not put "sleep" command in shell script, the server gives error.

In ssh panel:
Code:
./sendmail.sh

My excel file is in below form:

Code:
member1@hotmail.com    Name1    Surname1
member2@hotmail.com    Name2    Surname2
member3@hotmail.com    Name3    Surname3
member4@hotmail.com    Name4    Surname4
member5@hotmail.com    Name5    Surname5

Do not know which file extension should be used instead of excel file.
How can I change above script so that it reads mail-list database file and submit email to each member one by one with five seconds of interval.

Please help me.

Thanks
# 2  
Old 06-08-2013
There are some tools that can directly read Excel files, but an easy way to process data from an Excel spreadsheet is to export that data into a CSV (comma separated values) format file. You can then easily use the shell read command (with IFS=","), awk (with FS=","), and lot of other tools to extract the data you want from the CSV file and invoke sendEmail in a loop.
This User Gave Thanks to Don Cragun For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Help with reading and calling a command in a script

The problem I am having now is calling and reading a command and The Main script reads the data file and passes the input to the two calculation scripts, and than output to a file. 1. The Main Script ----------------- input=inputfilepj3 output=outfilepj3 echo "*** Converting... (2 Replies)
Discussion started by: TheUnitedOSI
2 Replies

2. Shell Programming and Scripting

how to assign ip after reading it from a database

Hi, I'm new to Red Hat. i have a database "work1" which has a table "dd_interface". This table has a column "ip", i have displayed this ip on the command terminal, i want this ip to be assigned eth0.... Can anyone help me with this???? Regards, Owais ---------- Post updated at 02:54 PM... (1 Reply)
Discussion started by: Owais.Ahmad
1 Replies

3. Shell Programming and Scripting

sendEmail: Script and Array

I have a script that send email using sendEmail (CentOS shell) script is: sendEmail -vvv -u "TestCompany, Inc.: USB Added" -f user@domain.com -t To@domain.com -s ASPMX.L.GOOGLE.com -m "USB Activity" -o tls=aut o username=user3@domain.com password=password So far this works fine. Now i... (5 Replies)
Discussion started by: kashif.live
5 Replies

4. Programming

Reading rpm database from windows.

Hello, I want to read a rpm database through my program in c ,I searched for it and found there is one library openly available that is rpmlib thorugh which we can access rpm databse but I want to use it from windows is it possible to read one rpm database from windows,I want to read the... (4 Replies)
Discussion started by: pradiptart
4 Replies

5. Shell Programming and Scripting

script to check for existence of file (or else sleep for x time)

Hi Forum. I have a script that accepts 3 input parameters (source directory, list file text, sleep time) and checks for the presence of files. If not there, script goes to sleep for certain amount of time provided by 3rd input. list file text contains 1 entry but may contain more (file... (13 Replies)
Discussion started by: pchang
13 Replies

6. Shell Programming and Scripting

passing database password to isql command in shell script

Hi, I need to connect to DB through my shell script. but I dont want to hardcode my db password in the script. Is there a way to do it? Thanks ---------- Post updated at 07:42 PM ---------- Previous update was at 04:54 PM ---------- :(Guys..please help me with this:( (1 Reply)
Discussion started by: agrawal.prachi
1 Replies

7. Shell Programming and Scripting

Reading data from DataBase and Writing to a file

Hi All, Please help me in writing data to a file in one row. In database there is a column which contains large data which does not fit in the file in one row. The column contains list of paths. I want to write these paths to a file in one row. Please find the code below writes : ... (2 Replies)
Discussion started by: rajeshorpu
2 Replies

8. Shell Programming and Scripting

question about "sleep" command in expect script

I wrote some expect script to telnet to some device to execute some commands.Firstly,I can't get full result some time,then I try to add some "sleep" command in it.Fortunately it works. My idea about it is that it uses sleep command to wait the result to be displayed.Am I right or correct the... (4 Replies)
Discussion started by: robbiezr
4 Replies

9. Shell Programming and Scripting

how to insert data into database by reading it from a text file??

Hi....can you guys help me out in this script?? Below is a text file and it contains these: GEF001 000093625 MKL002510 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL003604 000001 000000 000000 000000 000000 000000 000001 GEF001 000093625 MKL005675 000001... (4 Replies)
Discussion started by: pallavishetty
4 Replies

10. Shell Programming and Scripting

reading command output from shell script

Hi List, How to read the output of a command executed from a script. For ex. sample_scritp.sh ------------- useradd testuser1 password testuser1 .... ..... -------------- This prompts for "password", and "confirm password", for which i need to give the values from script. Can... (4 Replies)
Discussion started by: sri b
4 Replies
Login or Register to Ask a Question