Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
415
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.35 KB | None | 0 0
  1. HEADERS_ESCAPED="$(echo "$HEADERS" | sed -n 's/./\&/gp')"
  2. # double-useless use of cat BTW
  3. sed "s/TMPHEADERS/$HEADERS_ESCAPED/" /test/emailtemplate > /test/output
  4.  
  5. sed -n -e s/X/"$X"/ -e s/Y/"$Y" -e s/Z/"$Z"/ -e p inputfile > outputfile
  6.  
  7. while IFS= read -r line; do
  8. line="${line/TMPDATE/"$TMPDATE"}"
  9. # ...
  10. line="${line/TMPHEADERS/"$HEADERS"}"
  11. printf '%sn' "$line"
  12. done <inputfile >outputfile
  13.  
  14. perl -e 'open(A,"header"); ## open the header file
  15. $h=join("",<A>); ## save its contents in a string
  16. while(<>){ ## go through the input file
  17. s/TMPHEADERS/$h/; ## replace
  18. print ## print each line
  19. }' template
  20.  
  21. perl -e 'open(A,"header1");
  22. $h1=join("",<A>);
  23. open(B,"header2");
  24. $h2=join("",<B>);
  25. while(<>){
  26. s/TMPHEADERS/$h1/;
  27. s/TMPSOURCEIP/$h2/;
  28. print
  29. }' template
  30.  
  31. $ m4 -DTMPDATE="$(date)" -DTMPSOURCEIP="1.1.1.1" -DTMPHEADERS='include(headers.txt)' template.txt
  32. Alert Report
  33.  
  34. Alert has triggered at Mon Sep 25 18:46:34 CEST 2017
  35.  
  36. HEADERS
  37. -------
  38. From foo@yahoo.com Thu Apr 25 20:18:19 2013
  39. Return-Path: <foo@yahoo.com>
  40. Received: from nm30-vm0.bullet.mail.ne1.yahoo.com (nm30-vm0.bullet.mail.ne1.yahoo.com [98.138.11.36])
  41. by serv.example.com (8.14.4/8.14.4) with ESMTP id r3Q3IJVV009411
  42. (etc.)
  43.  
  44.  
  45. SOURCE IP
  46. ---------
  47. 1.1.1.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement