Jeffrey Parker had,
P>INBOXSIZE=`ls -l ${ORGMAIL} 2>/dev/null | awk '{print $5}'`
Dallman Ross suggested,
R>Why not just
R> INBOXSIZE = `wc -c < $ORGMAIL 2>/dev/null`
Paul Chvostek commented,
C> I think it's debatable whether you generate more load by parsing the
C> directory listing through a two-part pipe versus shovelling the
C> entire mailbox into a smaller pipe. Of the two solutions, I'd go for
C> the directory entry, so that a 20MB mailbox didn't generate 20MB of
C> data being read from the disk every time a message comes in.
OK, but since both approaches invoke $SHELL anyway, I think we can get
the best of both worlds:
:0i
INBOXSIZE=| set -- `ls -l $ORGMAIL` ; echo $5
or if you use anything in the csh family as $SHELL,
:0i
INBOXSIZE=| sh -c 'set -- `ls -l $ORGMAIL` ; echo $5'
I'm not sending stderr to /dev/null, because if $ORGMAIL can't be ls'ed,
I'd like the logfile to tell me!
Paul continued,
C> As I've mentioned before, my solution to this was to write a small C
C> program which is lighter-weight than either of these approached.
C> It's at http://www.it.ca/software/fsizecompare.c for your viewing
C> pleasure.
But some users are on accounts without access to compilers[*]. If we do
have compiler access, a program that just reports filesize without
requiring another number for comparison would be more versatile, and it
would still do the job:
LOCKFILE=$ORGMAIL$LOCKEXT
:0 flags
* $ `sizeoffile $ORGMAIL`^0
* 1^1 >1
* $ -$QUOTA^0
action # whatever you do if the message can't fit
:0E # regional lockfile is in effect
$ORGMAIL
LOCKFILE
All of these ideas need regional locking so that two procmails don't end
up expecting to use the same remaining disk allotment.
[*] Here's a twist on that: on one of my shell accounts, I have access
to cc and gcc, but the resulting binaries compiled on a machine with
shell logins won't run on the machine where incoming mail is processed.
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail