procmail
[Top] [All Lists]

Re: locking two files in one recipe

1997-04-25 09:04:00
era eriksson <reriksso(_at_)cc(_dot_)helsinki(_dot_)fi> writes:
On Thu, 24 Apr 1997 20:39:10 -0700 (PDT),
MAILBOX <dnhunt(_at_)rain(_dot_)org> wrote:
I have a recipe that writes to two different files in different
directories, and I need to lock them both. 
<...>
Can more than one lockfile be designated? 

Check out the LOCKFILE special variable. 

    :0 chiw: "$FILE.lock"
    | echo ; echo "$FROM" >> "$FILE" ; \
    sort -bdfu "$FILE" -o "$FILE" ; \
    echo "$DATA" >> "$LOG"

Try this:

   LOCKFILE="$LOG$LOCKEXT"

   :0 chiw: "$FILE$LOCKEXT"
   | echo; echo "$FROM" >>"$FILE"; \
     sort -bdfu "$FILE" -o "$FILE"; \
     echo "$DATA" >>"$LOG"

   LOCKFILE=

What's the first echo for? And are you really locking Procmail's log
file? (I don't think it's dangerous, but I also don't think Procmail
itself will honor the lock.)

Furthermore, when you assign to LOG to specify where to echo $DATA to,
procmail will write the value to the logfile.  If all that last echo
is there for is to write the value of DATA to the logfile, you could
simplify to:

        :0 chiw: $FILE
        | echo "$FROM" | sort -bdfu -o "$FILE"

        LOG = "$DATA
        "


Philip Guenther

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