procmail
[Top] [All Lists]

Re: Resending using formail from the command line

2002-06-03 13:50:33
On Mon, 3 Jun 2002, David W. Tamkin wrote:

Michelle had asked,

< I'm trying to resend some mail that was mistakenly delivered to
< /var/mail/<user> instead of ~<user>/.mail before I got procmail
< completely configured to deliver mail to spools in users' home
< directories.

And Udi suggested,

cd /var/mail
/bin/ls | sed 's/.*/formail -s /usr/sbin/sendmail & < &/' | sh

Noticing the slash problem, Udi revised that to this:

| /bin/ls -d | sed -n 's,^[a-z0-9][a-z0-9]*$,formail -s /usr/sbin/sendmail -i
&
| < &,p' | sh

Even so, it shouldn't take all the uses of ls, sed, and sendmail.

#!/bin/sh
cd /var/mail
for user in *
do
  [ -s $user ] && formail -s procmail -d $user < $user
done

Since you are already running that script as root in order to read all the
users' mail spools, you can use procmail's -d option even if procmail is not
setuid root.


        Yes, that's better, in case of busy machine my script is really
        wasteful but in case of emergency I prefer the oneline command line.

        Anyway, I think that '*' will take lockfiles, tmpfiles, strangefiles
        and directories, to avoid this I use the "-d" in ls(1) and "[a-z0-9]*"
        in sed(1).  Empty files are not so critical (for my taste).

Bye,
 Udi

_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail