Filtering mail into a named pipe


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Filtering mail into a named pipe
# 1  
Old 05-12-2010
Filtering mail into a named pipe

Hello,

On my machine, all mail is stored in my /var/spool/mail.

IS there a way to direct all mail that goes there into a namep pipe?

Thank you,
Dado
# 2  
Old 05-13-2010
You can pipe the email to a script by changing the alias file (/etc/mail/aliases)
add:
john: john,|myprocess

The email will be processed as standard input by "myprocess". Don't forget to allow for the header records.
This User Gave Thanks to jgt For This Post:
# 3  
Old 05-13-2010
Quote:
Originally Posted by jgt
You can pipe the email to a script by changing the alias file (/etc/mail/aliases)
add:
john: john,|myprocess

The email will be processed as standard input by "myprocess". Don't forget to allow for the header records.
What are header records?
# 4  
Old 05-13-2010
All of the records in the email ahead of the Subject line.
Usually.
From: ssssss
To:
Date:
Remarks: mmmmm

etc.
Look in /var/spool/mail/user, and look at all of the lines before the "useful" content of the email.
Something that I found really useful for this type of processing, assuming you have control of the incoming email, is to add a Remarks: line with a unique identifier in it, that you can reference back to the sending process.
EG

Remarks: 12343 (invoice number)

The recipient does not see the line unless they show all headers.
# 5  
Old 05-18-2010
Code:
# .procmailrc
# routes incoming mail to appropriate mailboxes
PATH=/usr/bin:/usr/local/bin
MAILDIR=/var/spool/mail   # all mailboxes are in .mailspool/
DEFAULT=/var/spool/mail
LOGFILE=/var/log/procmail
SHELL=/bin/bash

Can I not set this to send mail to directly to a named pipe?
Like, make it /var/spool/mail : (pipe name) ?

Last edited by dadoprso; 05-18-2010 at 11:17 AM.. Reason: accidently made a frown face
 
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 test named pipe file?

Hi ALL, How can I test a given file name exists and if it is a named pipe file in shell script ? Thanks............ (2 Replies)
Discussion started by: mycode.in
2 Replies

2. UNIX for Dummies Questions & Answers

Named pipe hanging?

Ok, I can't seem to figure this out or find anything on the web about this. I'm on Sun Solaris, UNIX. I have the following test script: #!/bin/ksh touch test.file LOG=./tmp.log rm -f ${LOG} PIPE=./tmp.pipe mkfifo ${PIPE} trap "rm -f ${PIPE}" EXIT tee -a ${LOG} < ${PIPE} & ... (17 Replies)
Discussion started by: Ditto
17 Replies

3. Programming

Named pipe behavior in Linux

Hi All ! I try to collect importent events from syslog and in my syslog conf, there is something like this: *.* |/logs/ipes/SLpipe1 I have a program, which opens this pipe and reads the messages from it. But how this pipe works ? Where can I probably read something about the details,... (3 Replies)
Discussion started by: mabra
3 Replies

4. Shell Programming and Scripting

Named pipe performance

Hi, I am getting data into a Named pipe. Does Named pipe have any size restriction; I know it does not have any storage and it just passes on the data to the next process. I want to know, if there will be a difference in the Named pipe performance if the data input is more. (I am using DB2... (1 Reply)
Discussion started by: sudvishw
1 Replies

5. UNIX for Advanced & Expert Users

will a named pipe always be size 0 on filesystem?

I did cat < myFile >> myPipe I was hoping that if I did ls -l, myPipe would now be holding the contents of myFile, and would be the same size. But it was 0. Also strange was that when I did the command above, cat did not return control back to the shell. Why? thanks (4 Replies)
Discussion started by: JamesByars
4 Replies

6. UNIX for Dummies Questions & Answers

Named Pipe contents to a file

I want to copy the contents of a named pipe to a file. I have tried using: cat pipe.p >> transcript.log but I have been unsuccessful, any ideas? (4 Replies)
Discussion started by: carl_vieyra
4 Replies

7. UNIX for Dummies Questions & Answers

Named PIPE

Gurus, I've a File Transaction Server, which communicates with other servers and performs some processing.It uses many Named PIPE's. By mistake i copied a named PIPE into a text file. I heard that PIPE files shouldn't be copied.Isn't it? Since it's a production box, i'm afraid on... (2 Replies)
Discussion started by: Tamil
2 Replies

8. UNIX for Advanced & Expert Users

named pipe with persistent buffer

Hey folks, i need communicate between 2 processes in a reliable manner. The information delivery has to be guarenteed. I thought about proc 2 sending a signal to proc 1 when information has being written to disc and wirte() has been verified (sync/flush). The IPC method for the data is named... (4 Replies)
Discussion started by: heck
4 Replies

9. Programming

IPC using named pipe

Hi All, I am facing a vague issue while trying to make two process talk to each other using named pipe. read process ========= The process which reads, basically creates FIFO using mkfifo - ret_val = mkfifo(HALF_DUPLEX, 0666) func. It then opens the pipe using open func - fd = open... (2 Replies)
Discussion started by: sharanbr
2 Replies

10. UNIX for Advanced & Expert Users

IPC using named pipe

Hi All, I am facing a vague issue while trying to make two process talk to each other using named pipe. read process ========= The process which reads, basically creates FIFO using mkfifo - ret_val = mkfifo(HALF_DUPLEX, 0666);) func. It then opens the pipe using open func - fd =... (1 Reply)
Discussion started by: sharanbr
1 Replies
Login or Register to Ask a Question