procmail
[Top] [All Lists]

Re: Save files in different folders

1996-07-26 17:04:05
Naveed Mustafa needs to do this:

| The procmail filter will have to determine from which server Mail has
| arrived and depending upon the name of the server, copy the body of the
| mail, which is actually the configuration of that server, to that server
| directory.

| The directory structure on Jupiter will be
| /usr/local/config/<server_name>/<server_name>.config

This reminds me of a situation I had on another ISP, where you normally let
the terminal server log you into a machine of its choice, but if you had
gotten disconnected during vi you had to be sure to specify the machine you
were on before so that you could recover your file; the recovery data would
be visible only on the machine that preserved it.

To do that I had a procmail recipe that recognized nvi's preservation
messages and appended "on <machine name>" to the subject line to make it
stand out which machine I had to use to recover the file.  I did that by
extracting it from the Message-Id: header.  Perhaps that will work for Naveed
as well, like so (with the exception that I just saved the message normally;
Naveed will need to keep only the body and to clobber the previous contents
of the config file):

  :0
  * conditions to recognize config mail
  * ^Message-Id:(_dot_)*(_at_)\/[^.>]+
  {
   CONFIGFILE=/usr/local/config/$MATCH/$MATCH.config

   :0b:$CONFIGFILE.lock
   | cat > $CONFIGFILE
  }

If you don't mind using a single lockfile for all of them, you can simplify
the code:

  :0b:/usr/local/config/.lock
  * conditions to recognize config mail
  * ^Message-Id:(_dot_)*(_at_)\/[^.>]+
  | cat > /usr/local/config/$MATCH/$MATCH.config

[Sometimes it would be nice to have a clobber flag for the flag line instead
 of needing to name the lockfile and use "| cat >".]

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