procmail
[Top] [All Lists]

Re: Procmail error "can't write ..."

2008-03-30 12:45:46
In message <47E90A73(_dot_)4000707(_at_)wavenet(_dot_)at>,
        Martin Hochreiter (linuxbox(_at_)wavenet(_dot_)at) wrote:

I am using the Horde module "Ingo" in my webmailsystem
and it generates me the procmail rule on the bottom of this mail.

I hope you didn't write it!  :-)

One line generates an error:

procmail: Executing " /bin/bash -c 'if [ $DATE -gt $START ]; then if [
$END -gt $DATE ]; then true; else false;fi;fi;'"
procmail: Error while writing to " /bin/bash -c 'if [ $DATE -gt $START
]; then if [ $END -gt $DATE ]; then true; else false;fi;fi;'"

I am not sure why you get this error - did it ever work? - since once I
had looked at the recipe I thought NO!  I am by no means a procmail
expert, but here is what I think is wrong.

------------------------------------ .procmailrc ----------------
[...]
  FILEDATE=`test -f '.vacation.martin.hochreiter' && ls -lcn
--time-style=+%s '.vacation.martin.hochreiter' | awk '{ print $6 +
(172800) }'`

Yuck!  stat(1) will give you the files date in the format you require in
one go, e.g. FILEDATE=`stat -f %s .vacation.martin.hochreiter`

  DATE=`date +%s`
  DUMMY=`test -f '.vacation.martin.hochreiter' && test $FILEDATE -le
$DATE && rm '.vacation.martin.hochreiter'`
  START=1206313200
  END=1206486000
 
  :0 Whc: vacation.lock
  | /bin/sh -c 'if [ $DATE -gt $START ]; then if [ $END -gt $DATE ];

Even more Yuck!

This will feed the message into the start of the pipeline which is not
required.

  :0 Whaf
  * ^TO_martin.hochreiter
  * !^X-Loop: martin.hochreiter
  * !^X-Spam-Flag: YES
  * !^From(_dot_)*root(_at_)XXX(_dot_)at
  * !^From(_dot_)*webmaster(_at_)XXX(_dot_)at
  * !^From(_dot_)*log(_at_)XXX(_dot_)at,
  * !^FROM_DAEMON
  | formail -rD 8192 .vacation.martin.hochreiter
    :0 ehc
    | (formail -rI"Precedence: junk" \
       -a"From: <martin.hochreiter>" \
       -A"X-Loop: martin.hochreiter" \
       -i"Subject: TEST Urlaubsmeldung" \
       -i"Content-Transfer-Encoding: quoted-printable" \
       -i"Content-Type: text/plain; charset=UTF-8" ; \
       echo -e "TEXT\n" \
      ) | $SENDMAIL -fmartin.hochreiter -oi -t

That seems okay, I think - I hate vacation mail. ;-)

This is what I came up with.  It uses procmail's scoring feature rather
than spawning a shell to make the date comparisons and so should be
quicker.

:0
* ? test -f .vacation.martin.hochreiter
{
  FILEDATE=`stat -f %m .vacation.martin.hochreiter`
  START=1206313200
  END=1206486000

  :0
  * $ $FILEDATE^0
  * $ -$START^0
  {
    :0
    * $ $END^0
    * $ -$FILEDATE^0
    {
      :0 Whf: vacation.lock
      * ^TO_martin.hochreiter
      * !^X-Loop: martin.hochreiter
      * !^X-Spam-Flag: YES
      * !^From(_dot_)*root(_at_)XXX(_dot_)at
      * !^From(_dot_)*webmaster(_at_)XXX(_dot_)at
      * !^From(_dot_)*log(_at_)XXX(_dot_)at,
      * !^FROM_DAEMON
      | formail -rD 8192 .vacation.martin.hochreiter
        :0 ehc
        | (formail -rI"Precedence: junk" \
           -a"From: <martin.hochreiter>" \
           -A"X-Loop: martin.hochreiter" \
           -i"Subject: TEST Urlaubsmeldung" \
           -i"Content-Transfer-Encoding: quoted-printable" \
           -i"Content-Type: text/plain; charset=UTF-8" ; \
           echo -e "TEXT\n" \
          ) | $SENDMAIL -fmartin.hochreiter -oi -t
    }
  }
}

Of course the clever thing to do would be to store the START and END
values in a file or files.  Perhaps that is what FILEDATE was supposed
to be for?


Cheers,
       Nick.
-- 

____________________________________________________________
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

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