LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   Procmail : Cat from External File (https://www.linuxquestions.org/questions/programming-9/procmail-cat-from-external-file-508413/)

joseph 12-07-2006 10:04 PM

Procmail : Cat from External File
 
Hi guys,

i would like know how the procmail can cat an external file for checking whether the string pattern is same with the content of the external file .... for example like :

:0
* ^Subject:. cat external_file
/dev/null

i have tried like :
myfile=`cat /var/block`

:0
* ^Subject:.*${myfile}
/dev/null

but it didn't work .... anyone know whats wrong??

Thanks

unSpawn 12-08-2006 03:59 PM

Why not use fgrep?

joseph 12-11-2006 12:53 AM

Can u teach how to do it UnSpawn??

Thanks

unSpawn 12-11-2006 07:37 AM

myfile=`cat /var/block`
If you want to do that you're almost always doing some sort of rudimentary access list or spam filtering in which case you better look at Spamassassin unless constant reinvention of wheel is your thing. Anyway. Here's an extremely simplified example to do filtering based on email addresses. Start by echoing email addresses into a list (use some test addresses if you're gonna do this for real, OK):
Code:

]$ echo "emai@addre.ss > ~/.procmail/allowlist"
]$ echo "em@aiad.dress >> ~/.procmail/allowlist"

Now edit the global or personal procmailrc to add logging to troubleshoot / check recipes:
Code:

VERBOSE=on
DROPPRIVS=yes
LOGABSTRACT=all
LOGFILE=~/.procmail/logfile

Now add the recipe:
Code:

# Recipe: route email to named mailbox "~/mail/allow"
:0
* ? (formail -x From: | fgrep -iqf ~/.procmail/allowlist)
~/mail/allow

Done, save, quit. Test.

Please read the procmail and grep man pages for more info.


All times are GMT -5. The time now is 06:52 PM.