procmail
[Top] [All Lists]

(Parsing dates and) persistent lock files that never go away

2004-07-22 21:49:48
* Dallman Ross <dman(_at_)nomotek(_dot_)com> [2004-07-22 14:54]:

  YEAR=`formail -x "Date: " | sed -e 's/.* 
\([12]\{,1\}[90]\{,1\}[0-9][0-9]\) .*/\1/' \
                                  -e 's/^[^0][0-9]$/19&/g' \
                                  -e 's/^[0][0-9]$/20&/g'`

I don't even know what you are trying to do there.  But it doesn't work,
at least on my system:

  sed: 1: "s/.* \([12]\{,1\}[90]\{ ...": RE error: invalid repetition count(s)

In english, I'm trying to extract the Date: field using formail, then
the first sed instruction parses out the year only, which can be of
the form 19xx, 20xx, or xx.  If it is of the form xx, then the next
two sed instructions try to pre-pend a "19" or "20", whichever makes
the most sense.

It's interesting that you get an error on repitition counts.  My
version of sed has no issue with using \{,1\} to mean the
subexpression ahead of it may occur zero or one times.  

Whatever you are trying to parse, though, you surely wouldn't need
formail pipled through such a hairy sed thing to come up with some
some component of the year.  Maybe you will enlighten us.

I cannot think of any other way of parsing out the year, but I always
appreciate being shown a better or different way of doing things.

Does anyone know of a different way to extract the year?

I was actually planning to complicate the 'year extractor' even more,
because sometimes the Date: field is empty, non-existent, or invalid,
in which case I would want the YEAR variable to then try to contain
the year located in the date that trails at the end of the From_
field.

  in/drug_testing_${YEAR:-0000}

Does anyone see why a lock file would be created indefinately?  

No, but is $YEAR is a directory?  If so, then you don't want a
lockfile on the recipe.

That recipe results in delivery to the following mbox FILES (for
example):

  in/drug_testing_2003
  in/drug_testing_2004
  in/drug_testing_1997
  in/drug_testing_0000
  .
  .
  
You get the idea.  I think I could easily have many instances of
procmail trying to write to the same file, so because the delivery is
to a file (as opposed to a folder), I believe I need the lockfile.

Here are the respective lock files that would be created in the
instances above:

  in/drug_testing_2003.lock
  in/drug_testing_2004.lock
  in/drug_testing_1997.lock
  in/drug_testing_0000.lock
  .
  .
  
Those are the lockfiles that would persist forever, or until I
brutefully delete them.

I have not seen this lock file problem repeat since I increased my
LINEBUF size, so I'll have to do some more extensive testing, and come
back to this thread if the problem still exists.

____________________________________________________________
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