how to put subject and body to mail from two files


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting how to put subject and body to mail from two files
# 1  
Old 10-09-2011
how to put subject and body to mail from two files

Hi all,

My sample file is something like this,

Code:
ORA-00206: Message 206 not found;  product=RDBMS; facility=ORA

ORA-00202: Message 202 not found;  product=RDBMS; facility=ORA

ORA-27063: Message 27063 not found;  product=RDBMS; facility=ORA

ORA-00206: Message 206 not found;  product=RDBMS; facility=ORA

ORA-27063: Message 27063 not found;  product=RDBMS; facility=ORA

ORA-00221: Message 221 not found;  product=RDBMS; facility=ORA


I want to filter "ORA" codes (Ex: ORA-00206,ORA-00202..) and the other part in that line seperately.Then put ORA code part in to mail subject and other part in the mail subject and send mail for each line seperately.I want to do this for that file every hour.I have write script for that(ecept the every one hour part), with that I can do put the ORA code part to subject line but can't put the other part to the body of the mail.Please go thorough with my code and help me to do this.
Code:
awk '/ORA/ { print $0 }' awk1.log > new

a=0
while read LINE
do a=$(($a+1));
awk '/ORA-/ { print $0 }' new | cut -c -10 > new1
awk '/ORA-/ { print $0 }' new | cut -d ":" -f 2- new > new2
mail -s $LINE -r sj@xxxx.com sj@xxxx.com < /home/sss/new2 
echo $LINE;
done < new
echo "Final line count is: $a";

*** awk1.log is my original file and I grep only ORA line to 'new' file,then grep only ORA codes to 'new1' and other part to 'new2'.

*** I need grep code to grep awk1.log to 'new' every one hour.

Moderator's Comments:
Mod Comment Video tutorial on how to use code tags in The UNIX and Linux Forums.

Last edited by Franklin52; 10-10-2011 at 03:15 AM.. Reason: Please use code tags, thank you
# 2  
Old 10-10-2011
not correct :
Code:
awk '/ORA-/ { print $0 }' new | cut -d ":" -f 2- new > new2

correct :
Code:
awk '/ORA-/ { print $0 }' new | cut -d ":" -f 2- > new2

remove the "new" that is in bold, give another try and let us know if things are still not working

... by the way,

aren't you willing to do a

Code:
awk '/ORA-/ { print $0 }' $LINE | cut -d ":" -f 2- > new2

instead of

Code:
awk '/ORA-/ { print $0 }' new | cut -d ":" -f 2- > new2

???

also consider generating new1 and new2 with 1 read of "new" file :
Code:
awk -F: '/ORA-/{print $1 >"new1";sub($1 FS " ",z);$1=$1;print $0 >"new2"}' new

or one read of $LINE

Code:
awk -F: '/ORA-/{print $1 >"new1";sub($1 FS " ",z);$1=$1;print $0 >"new2"}' $LINE


Last edited by ctsgnb; 10-10-2011 at 10:54 AM..
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Required to get out put of log in tabular format in email body

Dears Please support I have out put in text file and look like below fixed inquiries - Click on MAX suffix http://server:port/app User Details http://server:port/app Audit User Detail Action hhttp://server:port/app fixed inquiries - Click on MAX suffix http://server:port/app User Details ... (13 Replies)
Discussion started by: mirwasim
13 Replies

2. Shell Programming and Scripting

Difficulty to send image in mail body.

I have jpg file in my server. I am facing difficulty while sending the image in body . appreciate your help to fix to below code. echo "--FILEBOUNDARY" echo "Content-Type: image/jpg" echo "Content-Disposition: inline; filename=\"tick.jpg\"" echo... (3 Replies)
Discussion started by: Jewel
3 Replies

3. Shell Programming and Scripting

Grep the last line and put on mail subject

I have mail: cat /home/oracle/scripts/dbsizedaily.txt | mail -s "$TODAY: PROD DB Size" $RECIPIENTS I like to get and put USED_GB and %USED of the very last row from /home/oracle/scripts/dbsizedaily.txt. /home/oracle/scripts/dbsizedaily.txt has : DATE TIME TOTAL_GB USED_GB ... (6 Replies)
Discussion started by: Daniel Gate
6 Replies

4. Shell Programming and Scripting

Mail with body

Hello All, I wish to mail after completion of code. I would like to include subject and body in it. I am not looking to read the body from other file but willing to provide the body in the command itself. Can i do this way? I am looking to pass some parameters to body and this will be possible... (1 Reply)
Discussion started by: forums123456
1 Replies

5. Shell Programming and Scripting

mail: subject and body text

HI, After giving the mail -e name@domain.com its asking the subject : after this its enter in to the body of the mail i.e. (in edit mode) How to end this edit process to send mail ? (2 Replies)
Discussion started by: thelakbe
2 Replies

6. Shell Programming and Scripting

unix mail body with attachment

How can I send mail with attachment in HP-UX I am able to send mail with specific body,but not successful while attaching a file. I am using the below command however it stuck : uuencode test.txt |mailx -s "Subject" <e-mail id> (5 Replies)
Discussion started by: gautamadak
5 Replies

7. Shell Programming and Scripting

How to mail with this body

Hi, i have a file ABC, i want to mail the contents of this file and i want to make the body of the mail per my choice like this: Hi All, This is the Report for today. <Browse of the File ABC> i am using : mailx -s "Today's Report" abcd@xyz.com << EOT Hi All, This is... (1 Reply)
Discussion started by: Prat007
1 Replies

8. AIX

Send mail attachments and have a mail body

Hi, How can I send mail attachments from shell script (AIX) and have a mail body as well ? Thanks in advance. (1 Reply)
Discussion started by: shibajighosh
1 Replies

9. UNIX for Dummies Questions & Answers

How to send body in a mail

Hi, How to send send body along with attachment in a mail given below is code to send mail with attachemnt.its working fine but i need to send some message as body of the mail. uuencode /prod/applc/ds_data/mac/working/nullctry.csv "nullctry.csv" | mailx -s "List Of Attendance"... (6 Replies)
Discussion started by: rajendragora
6 Replies

10. UNIX for Dummies Questions & Answers

How to get åäö in e-mail message body

First of all: Hi all, i´m a new unix user and i´m swedish so please bare with me. When i generate an e-mail on a unix server and send it through novell netware 5, i loose the swedish characters å, ä and ö in the body of the message, however they remain in the subject row. What to do? Anyone?... (4 Replies)
Discussion started by: de98luto
4 Replies
Login or Register to Ask a Question