Sponsored Content
Top Forums Shell Programming and Scripting Split email message with procmail Post 302821253 by waltari2001 on Friday 14th of June 2013 08:50:07 AM
Old 06-14-2013
Split email message with procmail

Hi,

I'm using procmail to ingest incoming messages. The goal is to split the message body into chunks and forward those to a different adddress. Here's a sample of the message body:


Code:
Group: testgroup
---------------------------------------
Host: test1.local:30200  
Type: conf
Alert: Host Down
Status: Open
Last Updated: 2013/06/13 14:11 GMT
Created: 2013/06/13 14:11 GMT
---------------------------------------
Host: test1.local:30000  
Type: conf
Alert: Host Down
Status: Open
Last Updated: 2013/06/13 14:11 GMT
Created: 2013/06/13 14:11 GMT
---------------------------------------
Host: test1.local:30500  
Type: conf
Alert: Host Down
Status: Open
Last Updated: 2013/06/13 14:11 GMT
Created: 2013/06/13 14:11 GMT
---------------------------------------
---------------------------------------
Configure alerts: Go to this URL

The trick is to extract anything between the 2 delimiters (/^Host:/ && /^Created:/) and mail them. The sample above should result in 3 distinct messages:

Message1:
Code:
Host: test1.local:30200  
Type: conf
Alert: Host Down
Status: Open
Last Updated: 2013/06/13 14:11 GMT
Created: 2013/06/13 14:11 GMT

Message2:
Code:
Host: test1.local:30000  
Type: conf
Alert: Host Down
Status: Open
Last Updated: 2013/06/13 14:11 GMT
Created: 2013/06/13 14:11 GMT

Message3:
Code:
Host: test1.local:30500  
Type: conf
Alert: Host Down
Status: Open
Last Updated: 2013/06/13 14:11 GMT
Created: 2013/06/13 14:11 GMT

Thanks for the help!

Waltari

Last edited by Scott; 06-14-2013 at 10:11 AM.. Reason: Please use code tags
 

9 More Discussions You Might Find Interesting

1. UNIX for Advanced & Expert Users

email attachment, with a message using mailx

Hi, I am trying to include a message along with an attachment with an email using mailx on AIX. uuencode Test.dat Test.dat| mailx -s 'Testing' mymail@yahoo.com < MESGFILE This only gives me the contents of MESGFILE as my message. If I remove the < FILE I recieve the attachment. What... (4 Replies)
Discussion started by: edog
4 Replies

2. UNIX for Dummies Questions & Answers

Split-Email-removing files

Friends, I have a datafile that have unknown a number of CHARACTERS. if the datafile have more than 1 character and less than 20 email me the file rm datafile if the datafile have more than 20 characters split the datafile into 20 characters in each file email datafileaa email... (4 Replies)
Discussion started by: bobo
4 Replies

3. UNIX for Dummies Questions & Answers

Procmail 3.22 install error message

I'm trying to install : Procmail 3.22 onto a : E10K domain running : Solaris 2.6 Generic_105181-35 I untar the file to /stage/procmail-3.22. When I run the command: /usr/ccs/bin/make install I get the following message, then the install aborts: License Error : Cannot find license... (2 Replies)
Discussion started by: antalexi
2 Replies

4. Shell Programming and Scripting

error-when trying to send the message thru email.

Hi All, I want to send a message through email. I have written below code. But it is not worling. Anybody has idea, why it is not working?. export $file1=$home1/pip1.$$ mailx -s "This Message from unix" abc@yahoo.com< $file1 thanks,Mary. (5 Replies)
Discussion started by: MARY76
5 Replies

5. Shell Programming and Scripting

how to send contents of a file to email as a message

i have a file new1.txt i want to send the contents of that file as a message to email ali@sms.com i m using ksh script......... plz help me (5 Replies)
Discussion started by: ali560045
5 Replies

6. Shell Programming and Scripting

Email alert doesnt contain any message

I have created a script which will monitor disk space in unix, it will send an email alert that will notify the specified receipients. I used echo in the mailx command but the email doesnt contain any message. I have used printf to store the message ($message2) and when tried to display on the... (2 Replies)
Discussion started by: lscanaleta
2 Replies

7. UNIX for Dummies Questions & Answers

How to get failure notice message when email is not sent.

I am using mailx command to send emails from the Unix command prompt. Whenever email is not sent it is not giving me any message "Email not sent" or failure delivery notice for the wrong email addresses. When I give correct email address I am able to receive them correctly. Can anyone please... (0 Replies)
Discussion started by: szc0025
0 Replies

8. UNIX and Linux Applications

Ssmtp -t < /path/to/the/message.txt (How to format message.txt for html email)

ssmtp has been running well under Kubuntu 12.04.1 for plain text messages. I would like to send html messages with ssmtp -t < /path/to/the/message.txt, but I cannot seem to get the message.txt file properly formatted. I have tried various charsets, Content-Transfer-Encoding, rearranging the... (0 Replies)
Discussion started by: Ronald B
0 Replies

9. Shell Programming and Scripting

Message Body while sending an email

I am making use of the following code to display the results of my txt file in an email: mail -s 'Count Validation Test Comparison Results' Ronit@XYZ.com < Count_Validation_Results_`date +%m%d%Y`.txt Email Output: ----------Query 1 Count Validation Results-------- Source count is 4 Target... (7 Replies)
Discussion started by: ronitreddy
7 Replies
libapache2-mod-perl2-2.0.7::docs::api::APR::Date(3pm)	User Contributed Perl Documentation  libapache2-mod-perl2-2.0.7::docs::api::APR::Date(3pm)

NAME
APR::Date - Perl API for APR date manipulating functions Synopsis use APR::Date (); # parse HTTP-complient date string $date_string = 'Sun, 06 Nov 1994 08:49:37 GMT'; $date_parsed = APR::Date::parse_http($date_string); # parse RFC822-complient date string $date_string = 'Sun, 6 Nov 94 8:49:37 GMT'; $date_parsed = APR::Date::parse_rfc($date_string); Description "APR::Socket" provides the Perl interface to APR date manipulating functions. API
"APR::Date" provides the following functions and/or methods: "parse_http" Parse HTTP date strings $date_parsed = parse_http($date_string); arg1: $date_string ( string ) The date string can be in one of the following formats: Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format refer to RFC2616 for the details (GMT is assumed, regardless of the used timezone). ret: $date_parsed ( number ) the number of microseconds since 1 Jan 1970 GMT, or 0 if out of range or if the date is invalid. since: 2.0.00 Remember to divide the return value by 1_000_000 if you need it in seconds. "parse_rfc" Parse a string resembling an RFC 822 date. It's meant to be lenient in its parsing of dates. Hence, this will parse a wider range of dates than "parse_http()". $date_parsed = parse_rfc($date_string); arg1: $date_string ( string ) The date string can be in one of the following formats: Sun, 06 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sunday, 06-Nov-94 08:49:37 GMT ; RFC 850, obsoleted by RFC 1036 Sun Nov 6 08:49:37 1994 ; ANSI C's asctime() format Sun, 6 Nov 1994 08:49:37 GMT ; RFC 822, updated by RFC 1123 Sun, 06 Nov 94 08:49:37 GMT ; RFC 822 Sun, 6 Nov 94 08:49:37 GMT ; RFC 822 Sun, 06 Nov 94 08:49 GMT ; Unknown [drtr@ast.cam.ac.uk] Sun, 6 Nov 94 08:49 GMT ; Unknown [drtr@ast.cam.ac.uk] Sun, 06 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85] Sun, 6 Nov 94 8:49:37 GMT ; Unknown [Elm 70.85] ret: $date_parsed ( number ) the number of microseconds since 1 Jan 1970 GMT, or 0 if out of range or if the date is invalid. since: 2.0.00 Remember to divide the return value by 1_000_000 if you need it in seconds. See Also mod_perl 2.0 documentation. Copyright mod_perl 2.0 and its core modules are copyrighted under The Apache Software License, Version 2.0. Authors The mod_perl development team and numerous contributors. perl v5.14.2 2011-02-08 libapache2-mod-perl2-2.0.7::docs::api::APR::Date(3pm)
All times are GMT -4. The time now is 07:26 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy