On 3/16/21 11:34 AM, Per Jessen wrote:
I'm trying with this:
find /var/spool/mailman/bad -type f -name \*pck |
while read m do (mailman qfile $m | grep -q ad.dr@ess) && echo $m doneIs there a better way?
Yes, as you've noticed there is a significant startup cost every time
you invoke the mailman
command. to invoke it only once first see
mailman shell --details
(that refers to mailman withlist
which is just another way to spell
mailman shell
).
You will want to create a script similar to the following:
import pickle from os import listdir
def findaddr(address): for fname in listdir('/var/spool/mailman/bad'): if not fname.endswith('.pck'): continue with open(fname, 'rb') as fp: msg = pickle.load(fp) if address in msg.as_string(): print(fname)
That's your script. Save it as findaddr.py where mailman shell
can
import it and run
mailman shell -r findaddr.py -- ad.dr@ess
This should print the names of any pickles that contain 'ad.dr@ess'
Note however that this may not be necessary. If all you want is the names of the .pck files that mention 'ad.dr@ess',
grep ad.dr@ess /var/spool/mailman/bad/*.pck
should actually work reporting things like
Binary file /var/spool/mailman/bad/*.pck matches
with the actual file name, not *.
-- Mark Sapiro <mark@msapiro.net> The highway is for gamblers, San Francisco Bay Area, California better use your sense - B. Dylan