Parse text file values and send those files as an attachment

We have these files in say \home\abcd\dm

Summary.txt
log_SI-100.lst
log_SI-101.lst
log_SI-106.lst

The contents of Summary.txt is as below

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

Something like

cat $(sed 's/:[^.]*/ /g' summary.txt) | mailx -s "your subject" user@domain.com
1 Like

It works :slight_smile: ... 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??

YOURPATH=/tmp/whatever
cat $(sed "s/:[^.]*/ /g;s:[.]/:$YOURPATH/:g" summary.txt) | mailx -s "your subject" user@domain.com
1 Like

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

You can have a look at Command line/Script to send E-mail with HTML body and binary attachment Post: 302111802
or Email with multiple attachments & HTML body

you can also give a try to

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