LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 12-07-2006, 10:04 PM   #1
joseph
Member
 
Registered: Jun 2003
Location: Batam
Distribution: Ubuntu 10 And Linux Mint
Posts: 414

Rep: Reputation: 30
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

Last edited by joseph; 12-07-2006 at 10:08 PM.
 
Old 12-08-2006, 03:59 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
Why not use fgrep?
 
Old 12-11-2006, 12:53 AM   #3
joseph
Member
 
Registered: Jun 2003
Location: Batam
Distribution: Ubuntu 10 And Linux Mint
Posts: 414

Original Poster
Rep: Reputation: 30
Can u teach how to do it UnSpawn??

Thanks
 
Old 12-11-2006, 07:37 AM   #4
unSpawn
Moderator
 
Registered: May 2001
Posts: 29,415
Blog Entries: 55

Rep: Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600Reputation: 3600
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
cat file but don't quit Ephracis Linux - Software 2 08-26-2006 12:56 AM
filesize limit on 'cat $file | sed > $file' drkstr Linux - Software 2 07-10-2006 02:47 AM
trying to redirect text to a file to cat at later point. says file doesn't exist. dr_zayus69 Programming 1 10-02-2005 08:10 AM
Printing a new file over the old file using cat mrobertson Programming 4 07-07-2005 10:18 AM
Cat with Binary File? Xaque208 Linux - General 1 12-06-2004 07:59 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:21 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration