Combining header and data and send email without usage of temp file


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Combining header and data and send email without usage of temp file
# 1  
Old 04-14-2010
Combining header and data and send email without usage of temp file

Dear All-

My requirement is as below-
Header file
$ cat HEADER.txt
Code:
RequestId:
RequestDate:

Data file
Code:
$ cat DATAVAL.txt
1001|2009-03-01

I need to send the combined data below as email body [header+data] via mailx command
------------------
Code:
RequestId:1001
RequestDate:2009-03-01

I would like to achieve this using unix command alone and without usage of any temporary files to be created..


I tried something like below-
Code:
CMD1='cat CPG_HEADER.txt'
CMD2='tr -s "|" "\n" <CPG_VAL.txt'

e1=eval $CMD1
e2=eval $CMD2

Was trying to combine the above 2 evaluated command using paste command and then send via mailx, but this approach isn't working

Guys, please advice on this topic

Regards,
Suresh

Last edited by Franklin52; 04-14-2010 at 12:45 PM.. Reason: Please use code tags!
# 2  
Old 04-14-2010
Code:
awk -F\| 'NR==FNR{header[NR]=$0;next}{for (i=1;i<=NF;i++){print header[i] $i}}' HEADER.txt DATAVAL.txt

This might work as you expect
# 3  
Old 04-14-2010
Code:
nawk -F'|' 'FNR==NR {h[FNR]=$0;next}{for(i=1;i<=NF;i++) print h[i],$i}' HEADER.txt DATAVAL.txt | mailx myName@company.com

# 4  
Old 04-14-2010
Code:
#! /bin/sh
unpipe=$(tr '|' ' ' < file2)
function foo {
while read line; do echo "${line}${1}"; shift; done < file1
}
foo $unpipe



# ./test
RequestId:1001
RequestDate:2009-03-01
#

# 5  
Old 04-15-2010
Thank you guys..its working nw...any more suggestions are welcome...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Send Disk Space Usage Status via email

Hi Guys, Is there any way I can write a script that sends DISK SPACE USAGE STATUS via email once a week? Thanks, (5 Replies)
Discussion started by: g4v1n
5 Replies

2. Shell Programming and Scripting

Shell scripting unable to send the sql query data in table in body of email

I have written a shell script that calls below sql file. It is not sending the query data in table in the body of email. spool table_update.html; SELECT * FROM PROCESS_LOG_STATS where process = 'ActivateSubscription'; spool off; exit; Please use code tags next time for your code and data.... (9 Replies)
Discussion started by: Sharanakumar
9 Replies

3. Shell Programming and Scripting

Extract header data from one file and combine it with data from another file

Hi, Great minds, I have some files, in fact header files, of CTD profiler, I tried a lot C programming, could not get output as I was expected, because my programming skills are very poor, finally, joined unix forum with the hope that, I may get what I want, from you people, Here I have attached... (17 Replies)
Discussion started by: nex_asp
17 Replies

4. Shell Programming and Scripting

Combining data from file

Hi All, I have file f1 contains : f1; Server Name1 te-1212hdsfhf-12kll-56565 Server Name2 jd-1212hdsfhf-12kll-5677 Server Name3 ty-1212hdsfhf-12kll-444 .... I have to produce f2 with the output: f2: Server1 te-1212hdsfhf-12kll-56565 Server2 jd-1212hdsfhf-12kll-5677 Server3... (11 Replies)
Discussion started by: krsnadasa
11 Replies

5. Shell Programming and Scripting

Script to send email after comparing the folder permissions to a certain permission & send email

Hello , I am trying to write a unix shell script to compare folder permission to say drwxr-x-wx and then send an email to my id in case the folders don't have the drwxr-x-wx permissions set for them . I have been trying to come up with a script for few days now , pls help me:( (2 Replies)
Discussion started by: nairshar
2 Replies

6. Shell Programming and Scripting

mailx requirement - email body header in bold and data content in normal text

Dear all- I have a requirement to send an email via email with body content which looks something below- Email body contents -------------------- RequestType: Update DateAcctOpened: 1/5/2010 Note that header information and data content should be normal text.. Please advice on... (5 Replies)
Discussion started by: sureshg_sampat
5 Replies

7. Shell Programming and Scripting

Filter data and send email

Need script....We get sar file sa15 with 7 days data which gets appended.. we want filter and parse the outptu such that we should filter only last 48 hours data and then email it to out team. we read -- sar -f sa15 Please help me with the script either by use sar itself or even sar and awk... (10 Replies)
Discussion started by: noorm
10 Replies

8. Shell Programming and Scripting

Compare two csv files by two colums and create third file combining data from them.

I've got two large csv text table files with different number of columns each. I have to compare them based on first two columns and create resulting file that would in case of matched first two columns include all values from first one and all values (except first two colums) from second one. I... (5 Replies)
Discussion started by: agb2008
5 Replies

9. Shell Programming and Scripting

shell script to send email with usage of space in the directory as description :

shell script to send email with usage of space in the directory as description : Please any one help me in writing a script to send email with usage of space in the directory as description . (3 Replies)
Discussion started by: sakthifire
3 Replies

10. Shell Programming and Scripting

Need to send email on HIGH Disk usage

Hi Guys I am looking for a python / PERL script which will send me email when ever my disk becomes more than 90% full. By the way my OS is Win XP. If anybody have already has written same type of script or something very similar kind of script, that will also be very helpful. Thanks... (1 Reply)
Discussion started by: csaha
1 Replies
Login or Register to Ask a Question