procmail
[Top] [All Lists]

Re: mailbox map size check

2003-05-14 17:02:55
Tyler advised Sjaak,

Just make a call to the shell. Here is a less-than-optimal example:

:0c
| test `ls -s foo | awk '{ print $1 } '` -lt 8192 || mv foo bar;

Yes, less than optimal, and 8192 bytes are only 1/1024 of 8 MB (or is -s some option to -s that makes it print sizes in KB instead of bytes?), but it's the right idea. Another concern is that you don't want two procmail instantions fighting over which gets to do the mv, so the code needs a regional lockfile:

 LOCKFILE=$HOME/.backuptoobig$LOCKEXT

 :0ci
 * $ `wc -c < backup`^0
 * -8388608^0
 | mv backup backup.${TODAY:-`date +'%Y%m%d'`}

 LOCKFILE

If you're hot to avoid a shell,

 LOCKFILE=$HOME/.backuptoobig$LOCKEXT

 wcoutput=`wc -c backup`

 :0
 * wcoutput ?? ()\/[0-9]+
 * $ $MATCH^0
 * -8388608^0
 | mv backup backup.${TODAY:-`date +'%Y%m%d'`}

 LOCKFILE

and look, Ma, no shells!


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

<Prev in Thread] Current Thread [Next in Thread>