want to send 4 files output in one mail


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting want to send 4 files output in one mail
# 1  
Old 11-30-2011
want to send 4 files output in one mail

Hi All ,

i have a wrapper HTML script -FS_CHECK_HTML_SCIPT_WT_Statusbar.sh which read a TXT file (script_KB.txt) and sends output to a mail in tabular format. TXT file is having 6 columns and so wrapper script create a table with 6 columns and supplies those 6 columns data from TXT file .
my problem is - i have 4 TXT files and so i get 4 mails , 1 for each TXT file. i want to get 1 mail only for all those 4 TXT file but that mail should have 4 tables , 1 for each TXT file.

below is wrapper script , and format of TXT file :-
Code:
TXT file :-
rbs-siapp41 /prlocal 20971520 19089269 1773116 92%
bkp-simed01 /tkrep01/fs_users 52428800 46053961 5976435 89%

Wrapper Script :-

Code:
echo "/usr/sbin/sendmail TelkomselGICCINT@telkomsel.co.id<<EOF">/tmp/sendml123
echo "From: TBS-PROD@amdocs.com">>/tmp/sendml123
echo "To: TelkomselGICCINT@telkomsel.co.id">>/tmp/sendml123
echo "Subject:TBS - FS Alert Dated `date`">>/tmp/sendml123
echo "Content-Type: text/html; charset=\"us-ascii\"">>/tmp/sendml123
echo "<html><head>">>/tmp/sendml123
echo "<style type=\"text/css\">">>/tmp/sendml123
echo "#design">>/tmp/sendml123
echo "{">>/tmp/sendml123
echo "font-family:\"Trebuchet MS\", Arial, Helvetica, sans-serif;">>/tmp/sendml123
echo "border-collapse:collapse;">>/tmp/sendml123
echo "}">>/tmp/sendml123
echo "#design td, #design th">>/tmp/sendml123
echo "{">>/tmp/sendml123
echo "font-size:1em;">>/tmp/sendml123
echo "border:1px solid #98bf21;">>/tmp/sendml123
echo "padding:3px 7px 2px 7px;">>/tmp/sendml123
echo "}">>/tmp/sendml123
echo "#design th">>/tmp/sendml123
echo "{">>/tmp/sendml123
echo "font-size:1.1em;">>/tmp/sendml123
echo "text-align:left;">>/tmp/sendml123
echo "padding-top:5px;">>/tmp/sendml123
echo "padding-bottom:4px;">>/tmp/sendml123
echo "background-color:#A7C942;">>/tmp/sendml123
echo "color:#ffffff;">>/tmp/sendml123
echo "}">>/tmp/sendml123
echo "#design tr.alt td">>/tmp/sendml123
echo "{">>/tmp/sendml123
echo "color:#000000;">>/tmp/sendml123
echo "background-color:#EAF2D3;">>/tmp/sendml123
echo "}">>/tmp/sendml123
echo "</style>">>/tmp/sendml123
echo "</head> <body>">>/tmp/sendml123
echo "<h3>TBS FS ALERT </h3><br>">>/tmp/sendml123
paste /prlocal/celltadm/SCRIPT_REPOSITORY/SIM_DISK_CHECK/txt/script_KB.txt | awk '
BEGIN { print "<table id=\"design\" ><tr><th>Hostname<th>File Sys<th>TOTAL KB<th>USED KB<th>FREE KB<th>Status" }
{
        print "<tr><td>"$1"<td>"$2"<td>"$3"<td>"$4"<td>"$5"<td>"$6" "
}
        END { print "</table><br><br><br></body></html>\nEOF" }'>> /tmp/sendml123
ksh /tmp/sendml123
cat /tmp/sendml123
exit 0

Moderator's Comments:
Mod Comment How to use code tags

Last edited by Franklin52; 11-30-2011 at 03:29 AM.. Reason: Please use code tags for code and data samples, thank you
# 2  
Old 11-30-2011
Please use code tags next time.

Try changing the below snippet
Code:
paste /prlocal/celltadm/SCRIPT_REPOSITORY/SIM_DISK_CHECK/txt/script_KB.txt | awk '
BEGIN { print "<table id=\"design\" ><tr><th>Hostname<th>File Sys<th>TOTAL KB<th>USED KB<th>FREE KB<th>Status" }
{
print "<tr><td>"$1"<td>"$2"<td>"$3"<td>"$4"<td>"$5"<td>"$6" "
}
END { print "</table><br><br><br></body></html>\nEOF" }'


with this

Code:
awk '
BEGIN { print "<table id=\"design\" ><tr><th>Hostname<th>File Sys<th>TOTAL KB<th>USED KB<th>FREE KB<th>Status" }
{
print "<tr><td>"$1"<td>"$2"<td>"$3"<td>"$4"<td>"$5"<td>"$6" "
}
END { print "</table><br><br><br></body></html>\nEOF" }' file1 file2 file3 file4

# 3  
Old 11-30-2011
Hi Anchal ,

it will send multiple files output in same mail , but in same table also.
i want to differenciate between two tables (comes from two diff TXT files).
format shld be
Table 1 (from file 1)
Table 2 (from file2)

in same mail, with same column names

---------- Post updated at 02:39 PM ---------- Previous update was at 02:10 PM ----------

Anchal

i think i got it.Smilie
tried for two tables and i see two table in mail.

i removed "EOF" and redirected output of each file to 1 file and then redirected that file output to mail
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. Shell Programming and Scripting

Remove files send through mail

I wan't to remove last 5 and 10 days files from two directory and send the remove files list in mail Output send through mail find /kalia/cd/ -type f -mtime +5 exec rm {} \; find /kalia/uk/ -type f -mtome +10 exec rm {} \; Output send through mail File has been deleted ... (1 Reply)
Discussion started by: Kalia
1 Replies

3. Shell Programming and Scripting

I want query output to send on mail using table tag and output should be in table

#! /bin/ksh #] && . ./.profile 2>/dev/null if test -f '.profile'; then . ./.profile; fi; #. .profile LOG_DIR=/app/rpx/jobs/scripts/just/logs sendEmail() { pzCType="$1"; pzTitle="$2"; pzMsg="$3"; pzFrom="$4"; pzTo="$5"; pzFiles="$6"; pzReplyTo="$7" ( ... (21 Replies)
Discussion started by: ankit.mca.aaidu
21 Replies

4. Shell Programming and Scripting

How to write this script:- check output word and send a mail?

Hi Guys, I am not Good at scripting. I need to write a script such that if output of command shows the particular word in output then send mail to abc@compay.com -bash-3.2$ ps -ef | grep bpbkar root 6040 1 0 13:05:19 ? 0:00 bpbkar -r 2678400 -ru root -dt 47395 -to 0... (20 Replies)
Discussion started by: manalisharmabe
20 Replies

5. Shell Programming and Scripting

Send multiple HTML output in one mail

HI, I have two scripts which is sending the mail in html format. Script 1: 1.IFILE=/home/home01/Report.csv if #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:... (0 Replies)
Discussion started by: Vivekit82
0 Replies

6. UNIX for Dummies Questions & Answers

Converting txt output to rows and columns and send report via mail.

Hi All, I would like to send below output in a tabular column ( xml or excel ) and send a mail. vinay unix anil sql vamsee java request to suggest a solution. (1 Reply)
Discussion started by: Girish19
1 Replies

7. Shell Programming and Scripting

how to run a script using cron job and send the output as attachment via e-mail using unix

how to run a script using cron job and send the output as attachment via e-mail using unix. please help me. how my cron job entry should be? As of now my cron job entry is to run the script at specific time, 15 03 * * * /path/sample.sh | mail -s "Logs" email_id In the above entry, what... (8 Replies)
Discussion started by: vidhyaS
8 Replies

8. UNIX for Advanced & Expert Users

Output will send in mail

Hi All, Requirement is to select the data from database and send the output in mail. But the output should in HTML tabular format in mail body. For example my select command is : select ename,esal,edegn,dept from emp where deptno in (10,15); In the mail body the output should : Employee... (3 Replies)
Discussion started by: alex_us
3 Replies

9. Shell Programming and Scripting

How to send mail with multiple files attached?

Hi, I would like to send a mail with multiples files attached. Until now i was doing a "find" and then a "tar" of the text files. As I need to be able to read them on a mobile device such as Blackberry for instance, i would like to send them in one single mail, but without taring them. is... (2 Replies)
Discussion started by: Pierrito
2 Replies

10. UNIX for Advanced & Expert Users

send all mail to files instead of relaying out

I had a wierd request from one of our guys. We are running on RedHat EL5. He asked that all mail originating from 3 servers he owns be sent to files instead of being sent out. My first thought is to set "Smart" relay host in sendmail.cf on each of the 3 servers so all messages are sent to a 4th... (0 Replies)
Discussion started by: mglenney
0 Replies
Login or Register to Ask a Question