Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- HEADERS_ESCAPED="$(echo "$HEADERS" | sed -n 's/./\&/gp')"
- # double-useless use of cat BTW
- sed "s/TMPHEADERS/$HEADERS_ESCAPED/" /test/emailtemplate > /test/output
- sed -n -e s/X/"$X"/ -e s/Y/"$Y" -e s/Z/"$Z"/ -e p inputfile > outputfile
- while IFS= read -r line; do
- line="${line/TMPDATE/"$TMPDATE"}"
- # ...
- line="${line/TMPHEADERS/"$HEADERS"}"
- printf '%sn' "$line"
- done <inputfile >outputfile
- perl -e 'open(A,"header"); ## open the header file
- $h=join("",<A>); ## save its contents in a string
- while(<>){ ## go through the input file
- s/TMPHEADERS/$h/; ## replace
- print ## print each line
- }' template
- perl -e 'open(A,"header1");
- $h1=join("",<A>);
- open(B,"header2");
- $h2=join("",<B>);
- while(<>){
- s/TMPHEADERS/$h1/;
- s/TMPSOURCEIP/$h2/;
- print
- }' template
- $ m4 -DTMPDATE="$(date)" -DTMPSOURCEIP="1.1.1.1" -DTMPHEADERS='include(headers.txt)' template.txt
- Alert Report
- Alert has triggered at Mon Sep 25 18:46:34 CEST 2017
- HEADERS
- -------
- From foo@yahoo.com Thu Apr 25 20:18:19 2013
- Return-Path: <foo@yahoo.com>
- Received: from nm30-vm0.bullet.mail.ne1.yahoo.com (nm30-vm0.bullet.mail.ne1.yahoo.com [98.138.11.36])
- by serv.example.com (8.14.4/8.14.4) with ESMTP id r3Q3IJVV009411
- (etc.)
- SOURCE IP
- ---------
- 1.1.1.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement