E-mail Output Merge Lines for Some Text..


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting E-mail Output Merge Lines for Some Text..
# 8  
Old 06-20-2014
I'd rewrite your script like this:

Code:
# Author: Mohd Suhaimi Shariff
# Template for HTML E-mail
# 1st creation: Friday, May 18, 2012 04:07:14 PM
# 2nd creation: (add multi receipients)
[ $# -lt 3 ] && {
   echo "Usage: $0 subject content-file receipient [...]" >&2
   exit 2
}

export SUBJECT="$1"
export CONTENT="$2"
shift 2
(
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 echo '<HTML><BODY><PRE>'
 cat $CONTENT
 echo '</PRE></BODY></HTML>'
) | /usr/sbin/sendmail $@

This User Gave Thanks to Chubler_XL For This Post:
# 9  
Old 06-20-2014
With the original script in post #5 you could send to multiple recipients by using commas:
Code:
sh /EDWH-DMT02/script/MISC/email_v1.sh "my_email@company.com,my_email2@company.com,..." "$SUBJECT" "$CONTENT"


Last edited by Scrutinizer; 06-20-2014 at 04:06 AM..
This User Gave Thanks to Scrutinizer For This Post:
# 10  
Old 06-20-2014
Quote:
Originally Posted by Scrutinizer
With the original script in post #5 you could send to multiple recipients by using commas:
Code:
sh /EDWH-DMT02/script/MISC/email_v1.sh "my_email@company.com,my_email2@company.com,..." "$SUBJECT" "$CONTENT"

Thanks. It works!

Actually I've tried using the comma before but it doesn't work, only send the e-mail to the 1st list.

Is it because I used
Code:
sh /EDWH-DMT02/script/MISC/email_v1.sh "my_email@company.com, my_email2@company.com,..." "$SUBJECT" "$CONTENT"

instead of
Code:
sh /EDWH-DMT02/script/MISC/email_v1.sh "my_email@company.com,my_email2@company.com,..." "$SUBJECT" "$CONTENT"

Note the space in front of the ','

---------- Post updated at 03:35 PM ---------- Previous update was at 03:32 PM ----------

Quote:
Originally Posted by Chubler_XL
I'd rewrite your script like this:

Code:
# Author: Mohd Suhaimi Shariff
# Template for HTML E-mail
# 1st creation: Friday, May 18, 2012 04:07:14 PM
# 2nd creation: (add multi receipients)
[ $# -lt 3 ] && {
   echo "Usage: $0 subject content-file receipient [...]" >&2
   exit 2
}

export SUBJECT="$1"
export CONTENT="$2"
shift 2
(
 echo "Subject: $SUBJECT"
 echo "MIME-Version: 1.0"
 echo "Content-Type: text/html"
 echo "Content-Disposition: inline"
 echo '<HTML><BODY><PRE>'
 cat $CONTENT
 echo '</PRE></BODY></HTML>'
) | /usr/sbin/sendmail $@

Thanks.

But how do I use it?

---------- Post updated at 03:38 PM ---------- Previous update was at 03:35 PM ----------

By the way, by using my e-mail script above, when I received the e-mail, the recipient address is not displayed at all - totally blank.

Can I make it to display all the recipients?

Thank you.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Manipulate condition to send mail based on output text in file

Hi All, I have a working script as below. echo "Files loaded with $(cat /var/tmp/script.X1.out)" | mail -s "Files loaded with return code" mailid This script takes the output from script.X1.out file and appends the text "Files loaded with return code" and sends the email. Now what I want... (5 Replies)
Discussion started by: midhun3108
5 Replies

2. UNIX for Dummies Questions & Answers

Merge two text files by two fields and mixed output

Hello, I'm back again looking for your precious help- This time I need to merge two text files with matching two fields, output only common records with mixed output. Let's look at the example: FILE1 56153;AAA0708;3;TEST1TEST1; 89014;BBB0708;3;TEST2TEST2; 89014;BBB0708;4;TEST3TEST3; ... (7 Replies)
Discussion started by: emare
7 Replies

3. Shell Programming and Scripting

How to merge lines based off of text?

Hello Everyone, I have two files, similar to the following: File 1: 8010 ITEM01 CODE1 FLAG1 filler filler 7020 OBJECT CODE2 FLAG2 filler 6010 THING1 CODE4 FLAG4 6011 ITEM20 CODE7 FLAG7 File 2 contains: 6020 ITEM01 CODEA FLAGA filler filler filler 7000 OBJECT CODEB... (2 Replies)
Discussion started by: jl487
2 Replies

4. Shell Programming and Scripting

remove blank lines and merge lines in shell

Hi, I'm not a expert in shell programming, so i've come here to take help from u gurus. I'm trying to tailor a csv file that i got to make it work for the LOAD FROM command. I've a datatable csv of the below format - --in file format xx,xx,xx ,xx , , , , ,,xx, xxxx,, ,, xxx,... (11 Replies)
Discussion started by: dvah
11 Replies

5. Shell Programming and Scripting

Merge lines in text file based on pattern

Hello, I have searched forum trying to find a solution to my problem, but could not find anything or I did not understand the examples.... I should say, I am very inexperienced with text processing. I have a text file with approx 60k lines in it. I need to merge lines based on the number... (8 Replies)
Discussion started by: Bertik
8 Replies

6. Shell Programming and Scripting

Merge lines in a file with Awk - incorrect output

Hi, I would like: FastEthernet0/0 is up, line protocol is up 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored 0 output errors, 0 collisions, 0 interface resets Serial1/0:0 is up, line protocol is up 0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort 0... (14 Replies)
Discussion started by: mv652
14 Replies

7. Shell Programming and Scripting

Add text before lines in command output

Hi2all, I have following command in IBM HMC console: lssyscfg -r prof -m Server-9117-MMA-SN655D350 -F lpar_name,min_mem,desired_mem --header which gives me the following output: lpar_name,min_mem,desired_mem lpar1,1024,2048 lpar2,1024,2048 lpar3,2048,4096 What I want is to add in... (3 Replies)
Discussion started by: UsRb
3 Replies

8. Shell Programming and Scripting

need to search text and output previous lines

I have a file (OMlog0) that is quite large, I need to find the line "Automatic Recharge Audit Process Finished" and output that line and the time stamp that occurs two lines previous. The line that I was using is "sed -n '/Automatic Recharge Audit Process Finished/,/No errors/p' /sn/log/OM* >... (8 Replies)
Discussion started by: grinds
8 Replies

9. Shell Programming and Scripting

Cronjob - Redirect mail output to file, LINES & COLUMNS

I currently have an expect script that issues the 'mail' command and sends an 'x' when it receives the & prompt from mail to quit. The expect script is able to do stty rows 100 columns 200 < $spawn_out(slave,name) to set up the number of columns and rows. I would like to get rid of the expect... (0 Replies)
Discussion started by: jharvey
0 Replies

10. Shell Programming and Scripting

mail merge

dear friends plese give me full shell script for mail merge facilityu. i.e. to create a letter file i.e to create data file and report maile merge using shell scripitng. when run the programme ask for fields and store in a file and from another program when run that mail merge file... (3 Replies)
Discussion started by: cvvsnm
3 Replies
Login or Register to Ask a Question