On Mon, 31 Jan 2000 10:51:47 -0500, "W. Mark Herrick, Jr."
<markh(_at_)va(_dot_)rr(_dot_)com> wrote:
Below is a snippit from my .procmailrc file, and I'm wondering if I
have the lockfile in the correct place.
<...>
:0:
* !^FROM_DAEMON
* !^FROM_MAILER
* ^X-RR-Relay:
{
You can't use the default lock file notation here because Procmail
need something to tell it what the name of the lockfile should be. You
could name a lock file here (:0:mark-relay.lock if that's what you're
trying to lock) but you can't use a lock file on a block anyways IIRC
-- you probably want something like
:0
* conditions
{
LOCKFILE=mark-relay.lock
... actions inside braces ...
LOCKFILE # undefine LOCKFILE -- removes the lock
}
FWIW, you can use the :0: shorthand only if (1) the action is to save
to a file (in which case the lock file will be called file.lock, where
"file" stands for the name of the file you're writing to, of course)
or (2) if the recipe is a pipe which appends to a file with >> (in
which case the appended file's name plus .lock will be used for
locking). If your action doesn't meet either of these criteria, you
need to name the lock file (:0:filename.lock with an explicit file
name after the second colon). The LOCKFILE pseudovariable comes in
handy when you want to lock over a larger region than a single recipe
(and specifically the action part of the recipe in question -- the
lock will not happen unless the conditions are met; so the conditions
will not be executed under the lock at all).
The script in the 2nd part uses the contents of 'mark-relay' in
it's processing (grep/awk/sed/mailx), so I don't want 'mark-relay'
to be appended to until the script finishes...
Sounds like you should rewrite the script to read the message on its
standard input instead. You could amend the script with something like
this (off the top of my head):
#!/bin/sh # yes, I think it's silly to use bash for this
case $# in
1)
;;
*)
echo "syntax: $0 targetfile" >&2
exit 2 ;;
esac
trap 'rm -f "$@".lock' 1 2 3 15 # remove lock file if killed
lockfile "$@".lock || exit 1 # maybe you don't need this, even
cat - >>"$@"
... original script goes here
rm -f "$@".lock # done -- remove the lock file
If you are not nervous about using the script without locking in
general, perhaps you can move the locking back to Procmail (remove the
lines with comments on them), and simply keep the part which appends
to "$@" before proceeding with the rest of the script.
Hope this helps,
/* era */
--
Too much to say to fit into this .signature anyway: <http://www.iki.fi/era/>
Fight spam in Europe: <http://www.euro.cauce.org/> * Sign the EU petition