procmail
[Top] [All Lists]

Re: Scanning IMAP mail (first solution)

2009-11-16 13:07:35
On 16-Nov-2009, at 10:47, JW Simpson wrote:

  USER = `/usr/bin/id -un`

This value should already be in the variable LOGNAME.

Yes, but since I used id -un in the shell script, I decided to use the same 
exact thing in the procmail.

  :0c

You should use an i flag on your : line. ( w/thx2
http://mailman.rwth-aachen.de/pipermail/procmail/2009-November/028169.html )

  |(echo "Subject: $UNREAD unread mail(s)"; echo; echo "$NEWMAIL")| 
$SENDMAIL $MYAD

Use the -e flag with echo, so that you can avoid multiple calls to echo.
Also, Avoid using the ()'s, as they invoke a subshell.
If you are using /bin/echo, you should specify the path.  That decreases
the load time for the external echo command.

       | /bin/echo -e "Subject: $UNREAD unread mail(s)\n\n$NEWMAIL" |
       $SENDMAIL $MYAD

pretty sure when I tried that I lost the linefeeds on $NEWMAIL again.

UNAME=`id -un`

Again, this is already set as LOGNAME. 

Right. I can use $LOGNAME in both places.

rm /tmp/$UNAME.* 2>/dev/null

Use -f flag for rm to suppress output.  Then you don't have to use the
redirection.

Ah, yes, meant to do that after your last comment.

for i in `ls -A $HOME/Maildir/ | grep '[0-9]-*'`;

You don't need the call to grep.

       for i in `ls -A $HOME/Maildir/[0-9]-*`;

No, that doesn't work because $i will contain

/home/usr/Maildir/.mailbox.2009-11

with the grep, $i contains

.mailbox.2009-11


do ls −1 $HOME/Maildir/$i/{cur,new}/*, 2>/dev/null >>/tmp/$UNAME.$DATE.$i;

Don't use a tmp file.

       TMP=`ls −1 $HOME/Maildir/$i/{cur,new}/*, 2>/dev/null`

But that will result in a TMP that looks like this:

/home/kremels/Maildir/./cur/1258392839.2072_0.mail.covisp.net:2,
/home/kremels/Maildir/./cur/1258394552.M376650P6437V00000053I008E5E75_0.mail.covisp.net,S=381:2,
/home/kremels/Maildir/.applescript-users.2009-11/cur/1258389049.90346_0.mail.covisp.net:2,
/home/kremels/Maildir/.applescript-users.2009-11/cur/1258389482.92154_0.mail.covisp.net:2,
/home/kremels/Maildir/.applescript-users.2009-11/cur/1258389727.93154_0.mail.covisp.net:2,
/home/kremels/Maildir/.applescript-users.2009-11/cur/1258390041.93935_0.mail.covisp.net:2,
/home/kremels/Maildir/.applescript-users.2009-11/cur/1258391831.99023_0.mail.covisp.net:2,
/home/kremels/Maildir/.applescript-users.2009-11/cur/1258393220.3763_0.mail.covisp.net:2,
/home/kremels/Maildir/.iphone-talk.2009-11/cur/1258392161.347_0.mail.covisp.net:2,


You should stop there.  The rest can be handled by procmail "scoring".
Come to think of it... I think you can probably do the whole process
without the script.

I certainly don't see how.

if [ -s /tmp/$UNAME.$DATE.$i ]; then
  echo -n;

Use a : instead of echo.  (And your semicolon's are optional.)

Changed, thanks.

Also, it's just too slow.

The only reason I'm nitpicking ... is because you included that
statement.  :-D

Appreciated, believe me.


-- 
WORDS IN THE HEART CANNOT BE TAKEN --Feet of Clay


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)de
http://mailman.rwth-aachen.de/mailman/listinfo/procmail