Sponsored Content
Top Forums Shell Programming and Scripting Send multiple HTML output in one mail Post 302886460 by Vivekit82 on Friday 31st of January 2014 04:38:23 PM
Old 01-31-2014
Send multiple HTML output in one mail

HI,

I have two scripts which is sending the mail in html format.
Code:
 
 
Script 1:
 
1.IFILE=/home/home01/Report.csv
if [ -r $IFILE ]  #Checks if file exists and readable
then
if awk -F, '{ T += $13 } END { exit(!T) }' ${IFILE}
then
awk -F, 'BEGIN{
c=split("3,4,8,9,13", col)
print "To: abc@gmail.com"
print "Subject:REPORT"
print "MIME-Version: 1.0"
print "Content-Type: text/html"
print "Content-Disposition: inline\n"
print "<HTML><TABLE border=1>"
print "<TH>Code1</TH><TH>Bus</TH><TH>File1</TH>"
print "<TH>Code2</TH><TH>#tra</TH><TH>"
}
NR>4 {
printf "<TR>"
for(i=1;i<=c;i++) printf "<TD>%s</TD>", $col[i]
print "</TR>"
}
END{
  print "</TABLE></BODY></HTML>"
} ' ${IFILE} | sendmail -t
 
 
Script2:
 
IFILE=/home/home01/Report2.csv
if [ -r $IFILE ];  #Checks if file exists and readable
then
if awk -F, '{ T += $6 + $7 } END { exit(!T) }' ${IFILE}
then
awk -F, '
BEGIN{
 c=split("1,2,3,4,5,6,7", col)
 print "To: abc@gmail.com"
 print "Subject: REPORT2"
 print "MIME-Version: 1.0"
 print "Content-Type: text/html"
 print "Content-Disposition: inline\n"
 print "<HTML><TABLE border=1>"
 print "<TH>Orhaned Rule</TH><TH>File Entiity1</TH><TH>Entity 1 record Count</TH>"
 print "<TH>File 2</TH><TH>Entity2</TH>"
 print "<TH>Total</TH><TH>rejection</TH><TH>"
}
NR>4 {
 printf "<TR>"
 for(i=1;i<=c;i++) printf "<TD>%s</TD>", $col[i]
 print "</TR>"
}
END{
  print "</TABLE></BODY></HTML>"
} ' ${IFILE} | sendmail -t
fi
fi

Now if i am running the two scripts separately i am getting two output as required.
Is there any way to send the output of both the scripts in one mail.

I tried calling both the scripts from one main script final_script.sh where i tried to send the output of both he scripts to one flat file and then cat file and sending the mail..But it is not working and in output actual html code is getting printed.

I tried below:

Code:
 
log=/home/home01
rndt=`date +"%m%d%y%H%M%S"`
OFILE1="${log}/${rndt}.log"
/home/home01/1.sh >> ${OFILE1}
/home/home01/2.sh >> ${OFILE1}
cat $OFILE1 | sendmail -t abc@gmail.com

Output coming something like this:

Code:
 
<TR><TD>* * * * * End Of Report * * * * *</TD><TD></TD><TD></TD><TD></TD><TD></TD></TR>
</TABLE></BODY></HTML>

Before running above code i remove the
Code:
sendmail -t

command from each individual script.
Pls help.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

Using mail to send HTML emails

Hi, I'm a programmer not a sys admin, so please excuse this if it seems a little out of place, but I think it applies to this forum. When I send my HTML newsletter from the server it comes in as plain text on some email programs and not others. Eudora is fine; Outlook Express, Hotmail, and... (2 Replies)
Discussion started by: dmennis
2 Replies

2. Shell Programming and Scripting

Sending mail from Unix - For html output

I have automated some checks - and I want to send a email when there is an issue. This is fine and I can send the email. However - I want to generate the email in html format so I can highlight any issues to a reader.. ie. If there is a disk space issue - then the email will highlight the... (2 Replies)
Discussion started by: frustrated1
2 Replies

3. Shell Programming and Scripting

Send an attachment and html text both in the same mail

Hi all, I am working on UNIX (Solaris28). I would like to send an email in which the body will be in html format and, in the same mail, a xls file has to be attached. I have tried this: the file is correctly attached but the body comes as html source and not formatted. If I do not attach the... (4 Replies)
Discussion started by: stefan.yu
4 Replies

4. UNIX for Dummies Questions & Answers

AIX send mail with HTML message body and a binary attachment

I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command line switch to specify file name of a binary attachment 3. command line or input file to specify... (4 Replies)
Discussion started by: G-Man
4 Replies

5. AIX

Command line/Script to send E-mail with HTML body and binary attachment

I apoligize for the cross-post but I'm not getting much in the way of help in the dummies forum: I'm trying to script sending an e-mail message on an AIX 5.x server with the following requirements: 1. command line switch to specify file name containing message body in HTML format 2. command... (3 Replies)
Discussion started by: G-Man
3 Replies

6. Shell Programming and Scripting

Send mail with rich text / HTML with image

Hi, Is it possible to send mail from my HP-Ux system with images, rich text? I would like to program in such a way that I have my company's logo(.jpg) image attached in the mail geeting triggered. I would like to send a rich text/HTML email instead of plain text mail to the recipients. Is it... (2 Replies)
Discussion started by: rythym05
2 Replies

7. UNIX for Dummies Questions & Answers

How to send html file in a mail not as an attachment but it should display in the mail in table for

Hi The below script working when we are sending the html as attachment can u please guide how to send thesmae data in table form direct in the mail and not in mail attachment . cat Employee.sql SET VERIFY OFF SET PAGESIZE 200 SET MARKUP HTML ON SPOOL ON PREFORMAT OFF ENTMAP ON - HEAD... (0 Replies)
Discussion started by: mani_isha
0 Replies

8. Shell Programming and Scripting

Unable to send mail with inline html along with attachment. Please help!

The below code is not working. I am able to send only inline html or only attachment. When trying to do both, only inline html is sent without attachment. Please help! #!/bin/ksh (echo "Subject: Test Mail - HTML Format" echo "MIME-Version: 1.0" echo "Content-Type: text/html" echo... (1 Reply)
Discussion started by: thulasidharan2k
1 Replies

9. Shell Programming and Scripting

Send mail using html tag pre

Need assistance. Trying to send a test.csv file using html tag <PRE> </PRE>. Used to work without any issue . But now gets me and stdin issue. Please give me any suggestions #!/usr/bin/ksh export MAILTO=" <userid>@a.com" export SUBJECT="Test mail " ( echo "Subject: $SUBJECT" echo... (6 Replies)
Discussion started by: ajayram_arya
6 Replies

10. Shell Programming and Scripting

Script that gathers specific values from files and puts it into HTML to send e-mail

Hi All, Sorry for long topic here. So the drill goes like that, I need a script which gathers different values from different files/locations. A_CT=`cat a.dat | awk -F'|' '{print $1}' >> report.txt` B_CT=`cat b.dat | awk -F'|' '{print $3}' >> report.txt` C_CT=`cat c.dat | awk -F'|'... (4 Replies)
Discussion started by: shivakid
4 Replies
All times are GMT -4. The time now is 07:55 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy