procmail
[Top] [All Lists]

Re: rm a non-existent file

1997-10-16 00:04:32
On Thu, 16 Oct 1997 14:06:31 +0900,
Ralph Henderson <work(_at_)hendersonuk(_dot_)com> wrote:
From what I've figured out procmail acts up if you carry out an invalid
shell command. In my recipe I want to delete a file and I assume I have
to check if it exists first. Is this assumption correct?

Not entirely. Procmail will pass on error messages into the log, which
is not where you tend to look very often, unless you specifically
expect some sort of trouble. It is good practice to check your
assumptions before going ahead with your recipes, but Procmail is no
less unforgiving than the shell itself. An interactive shell script,
however, will tell you something is wrong up front (unless you run it
in nohup or redirect errors to /dev/null or just ignore it ... or it
acts up in ways that don't generate error messages :-)

I came up with the following recipe which works but looks really clumsy
<...>
:0 c: mailfile.lock
* ? test -e mailfile
| rm mailfile

:0 : mailfile.lock
mailfile

Just overwrite the file:

    :0:
    | cat >mailfile

Finally, is that lockfile needed?

Since you're overwriting the file, not really, I guess.

/* era */

-- 
 Paparazzi of the Net: No matter what you do to protect your privacy,
  they'll hunt you down and spam you. <http://www.iki.fi/~era/spam/>

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