Parse text file values and send those files as an attachment


 
Thread Tools Search this Thread
Top Forums UNIX for Advanced & Expert Users Parse text file values and send those files as an attachment
# 1  
Old 04-27-2011
Parse text file values and send those files as an attachment

We have these files in say \home\abcd\dm
Code:
Summary.txt
log_SI-100.lst
log_SI-101.lst
log_SI-106.lst

The contents of Summary.txt is as below
Code:
 
./log_SI-100.lst:Error detected, rollbacking ./log_SI-101.lst:Error detected, rollbacking ./log_SI-106.lst:Error detected, rollbacking 

Now i need a statement which will get all the file names from Summary.txt and then append the contents of these files and send it as an email.

For the above example, the contents of files
log_SI-100.lst
log_SI-101.lst
log_SI-106.lst
will be appended and sent as an email.. please help me out..

Last edited by Yogesh Sawant; 05-01-2011 at 07:36 AM.. Reason: added code tags
# 2  
Old 04-27-2011
Something like
Code:
cat $(sed 's/:[^.]*/ /g' summary.txt) | mailx -s "your subject" user@domain.com

This User Gave Thanks to ctsgnb For This Post:
# 3  
Old 04-28-2011
It works Smilie ... only thing is i have to be in the directory where these log_SI-100.lst
files are.. can i specify the path for these files in the code itself.. so that it wil work anywhere??
# 4  
Old 04-28-2011
Code:
YOURPATH=/tmp/whatever
cat $(sed "s/:[^.]*/ /g;s:[.]/:$YOURPATH/:g" summary.txt) | mailx -s "your subject" user@domain.com

This User Gave Thanks to ctsgnb For This Post:
# 5  
Old 05-02-2011
Same one.. but have to send those log files as an attachment and i have write something in the body of the mail.. how do i do that.. thanks
# 6  
Old 05-02-2011
You can have a look at https://www.unix.com/302111802-post2.html
or https://www.unix.com/unix-advanced-ex...html-body.html

you can also give a try to
Code:
YOURPATH=/tmp/whatever
cat $(sed "s/:[^.]*/ /g;s:[.]/:$YOURPATH/:g" summary.txt) >attachement.txt
( cat yourbodyfile ; uuencode attachement.txt attachement.txt ) | mailx -s "your subject" user@domain.com

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to send colorful text and attachment to mail

Hi, I want to send color text as body of mail with multiple attachments.How to do this?I used sendmailcommand but this command fails for multiple attachments.Give me some solution on this. :wall: (0 Replies)
Discussion started by: AhmedLakadkutta
0 Replies

2. Shell Programming and Scripting

Korn shell program to parse CSV text file and insert values into Oracle database

Enclosed is comma separated text file. I need to write a korn shell program that will parse the text file and insert the values into Oracle database. I need to write the korn shell program on Red Hat Enterprise Linux server. Oracle database is 10g. (15 Replies)
Discussion started by: shellguy
15 Replies

3. Shell Programming and Scripting

Send files as an attachment without uuencode

Hi All, Is there anyway we can send files as an attachment? I tried running uuencode but its giving an error as below: $ uuencode Z1.txt Z1.txt |mailx -s "hi" abc@abc.com ksh: uuencode: not found. Null message body; hope that's ok When i gave which command then it says there is no... (18 Replies)
Discussion started by: HemaV
18 Replies

4. AIX

Send mail with attachment having csv files

Hi, Could anyone please help me to send multiple files of .csv format in one mail. Thanks Aj (2 Replies)
Discussion started by: atinjain05
2 Replies

5. UNIX for Advanced & Expert Users

how to send file as attachment with mail ?

hello , i m new to linux/unix , well in my college their is linux server to which we all (i and my frnds) login , we can send mail to each other through command "mail" . but any one can tell me how can i attached a binary file with mail. we are using red hat , "pine ", "mailx" , all... (2 Replies)
Discussion started by: alert_every1
2 Replies

6. Shell Programming and Scripting

Script needed which will send a mail with attachment files

Hello, I need a shell script which need to send a mail with 4 *.csv files as attachments.Anybody can help me? At present i have a script which is sending only one file as attachments.But i need a script which send 4 files in a shot. #!/bin/ksh /bin/mail xxxx@xx.xom << EOF Subject:... (4 Replies)
Discussion started by: Mar1006
4 Replies

7. Shell Programming and Scripting

How to send the multi files as a attachment

Hi all, Could you please guide me to write the shell script, to send a multi file as a attachement . Thanks Murugesh (1 Reply)
Discussion started by: Murugesh
1 Replies

8. 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

9. UNIX for Dummies Questions & Answers

Parse Text file and send mails

Please help. I have a text file which looks something like this aaa@abc.com, c:FilePath\Eaaa.txt bbb@abc.com, c:FilePath\Ebbb.txt ccc@abc.com, c:FilePath\Eccc.txt ddd@abc.com, c:FilePath\Eddd.txt...so on I want to write a shell script which will pick up the first field 'aaa@abc.com' and... (12 Replies)
Discussion started by: Amruta Pitkar
12 Replies

10. UNIX for Dummies Questions & Answers

Send a *.pdf file as a attachment

Hi there, i am very new in the unix sector. (i work on HP UX, an Sun Solaris) i can write some simple scripts,..... but now i will wirte a script with "mail". i would like to send a pdf file to a mail recipient. But if i try it with "mail -s "email@adress" < "filename(with path)" it... (3 Replies)
Discussion started by: scotty
3 Replies
Login or Register to Ask a Question