Help in scripting for emailing notificatons


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Help in scripting for emailing notificatons
# 1  
Old 12-28-2011
Help in scripting for emailing notificatons

Hi all,

I have a table like this:

Name email booking no

xyz xyz@abc.com 1235
pqr pqr@abc.com 2536
xyz xyz@abc.com 5896

we have to send a notification to all distinct email ids with consolidated booking information in a single mail.

i.e.,

1235
2536 with some subject has to be sent to xyz@abc.com

5896 with some subject has to be sent to pqr@abc.com


Please help in scripting.
its urgentSmilie
# 2  
Old 12-28-2011
Try with this ..
Code:
$ nawk '{print "mailx -s \""$NF" with some content\" "$2}' infile | sh

# 3  
Old 12-28-2011
Similar one...
Code:
#!/bin/bash
while read name email count
do   
  echo "$count" | mail -s "Subject" $email
done < infile

--ahamed
# 4  
Old 12-28-2011
Please tell us what Operating System and version you have and what Shell you prefer.
For questions about email, please provide a sample email command which works on your system. Linux users tend to use "mail" whereas unix users tend to use "mailx" or "sendmail." There is a lot more variation than this.
# 5  
Old 12-28-2011
Thanks jayan_jay and ahamed for you response. Ill try both and get back to you in case of any issues.

Hi Methyl,

I am using windows Xp3.
using the tool "Putty" to work on Unix Operating system.
what else could matter?
# 6  
Old 12-28-2011
@dineshnarra
Windows XP with Putty just emulates a unix terminal.
It would help to know some information about the computer on which you will be running the commands!

Otherwise you may well get answers which only work on a different computer from yours. You already have answers suggesting both "mail" and "mailx" but you might actually have something quite different.
# 7  
Old 12-28-2011
I like to use sendmail, all my *nix system include it.
Here template is nice to use to make message body.

Something like:
Code:
# setup sendmail path
SM="/usr/lib/sendmail -t -i "
SENDER="some.sender@from.here"

########################
sendm()
{
From="$1"
To="$2"
Subject="$3"
shift 3
message="$*"

$SM <<EOF
From: $From
To: $To
Subject: $Subject

Accepted $( date '+%Y-%m-%d %H:%M:%S' )

$message

-xxxx-

EOF
}
########################

# here is only example to make test file, using ; separator between cols
cat <<EOF >$0.tmp
some name;some.name@some.domain;2234
Other Name;other name@other.xx;3333
EOF


oifs="$IFS"  # save org 
while IFS=";" read name email value xstr
do
        IFS="$oifs"
        sendm "$SENDER" "$email" "Your $value" "Hello $name, your number $value"
done < $0.tmp

rm -f $0.tmp

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Crontab 2>&1 not emailing

I have a script that emails me when I run it manually, but the crontab I'm using must be 'silencing' the output? Here's what I have: */15 * * * * /usr/src/blah.sh > /dev/null 2>&1 I don't want it to email me every time it runs, just when I run the sendmail command inside the script if the... (13 Replies)
Discussion started by: unclecameron
13 Replies

2. Shell Programming and Scripting

Need help on conditional emailing

Hi All, The following databse table maintains VENDOR and EMAIL details. VENOR_NAME VENDOR_EMAIL DELL surendra@dell.com HP rajkamal@hp.com ACER sumathi@acer.com NOKIA kunal@nokia.com SONY sinu@sony.com We have to find emaild id of a vendor based... (7 Replies)
Discussion started by: ROCK_PLSQL
7 Replies

3. AIX

Problem in Emailing all .sh_history entries

Hi, I can't get all the enties of AIX .sh_history in email. only first entry of the history is emailed after executing the below code. mail -s "History `date +%d-%m-%Y`" myemail@xyz.com <$HOME/.sh_history Can anyone help? (3 Replies)
Discussion started by: m_raheelahmed
3 Replies

4. UNIX for Dummies Questions & Answers

Shell script emailing issue

Hi, Im writing a shell script: #!/bin/bash #Send process which has exceeded 25% # echo 'pri pid user nice pcpu command' > /export/home/tjmoore/file2 # if ps -eo pri,pid,user,nice,pcpu,comm | awk '{if($5 >= 25)print $0}' >> /export/home/tjmoore/file2 2>/dev/null # # # then... (1 Reply)
Discussion started by: jay02
1 Replies

5. Shell Programming and Scripting

Automate emailing via shell script

Hi, I am struggling to send my email via shell script. I can type the command in and it works pefectly: mail -s "subject" email@email.co.email < text_to_sendHowever if I try and automate it it fails. I have tried setting variables for all aspects (mail, email addr, subject, message) with no... (3 Replies)
Discussion started by: mcclunyboy
3 Replies

6. Shell Programming and Scripting

emailing as body of email

hi all, how do i email a file in the body of an email rather than as an attachment ?? have a ksh script which i need to read a file and email as part of the body rather than an attachment. my code is : uuencode file.log | mailx -s "test" but this sends file as an attachment. ... (2 Replies)
Discussion started by: cesarNZ
2 Replies

7. Shell Programming and Scripting

script not emailing or running

Hi, I am having trouble with this script. It is suppose to send me an email when the specified tablespace is 60% full. I run it but nothing happens FREESPACELOG=/home/oracle/scripts/bin/free_space/freespace.sql email=bob@bob.edu subject="PROD: Tablespace Free Space" cmd="mailx -s... (1 Reply)
Discussion started by: shaseeb
1 Replies

8. Shell Programming and Scripting

Copying files and emailing them out

Hello everybody, I'm trying to create a script that will cd into a directory and then copy the file with yesterday's date on it and then cd into another directory doing the same thing. Afterwards, i'm trying to zip up the two files, and email them out to people. Can anyone help? thanks a... (1 Reply)
Discussion started by: jhofilena
1 Replies

9. Solaris

Emailing about password expiry for a user

How to create a mechanism that e-mails user/admin before password expiry. Assume 7 days in advance. Thanks in advance for your great help. Regards, Awadhesh (4 Replies)
Discussion started by: Awadhesh
4 Replies

10. UNIX for Dummies Questions & Answers

SMTP - emailing issue

We are running an application engine program that sends email to a list of users. In our Test Env, users are able to receive the emails but in our Prod environment, they do not. We are running the same program, and using the same stmp config. any idea on how to troubleshoot? (3 Replies)
Discussion started by: tads98
3 Replies
Login or Register to Ask a Question