procmail
[Top] [All Lists]

Re: x-hdr defining variable

1997-08-15 07:49:00
On Thu, 14 Aug 1997 17:28:54 -0400 (EDT), "[Top Secret]"
<web401a5(_at_)topsecret(_dot_)net> wrote:
what i would like to do is have the user include an x-header that defines 
the name of the file saved.  i will have predefined per alias the 
subdirectory the file gets saved to, the user will simply specify a 
filename that the document gets saved to with the x-header.
incidentally, if the file does not already exist it would need to be 
created.
i pipe the body into the cat statement, i've gotten that far, but i need 
to ask for help on defining and using the variable.  would someone be so 
kind as to forward me an example of using an x-header variable or insert 
the necessary code and/or comments into what i have here?  (feel free to 
comment on what is already here)

Useless Use of Cat. Unless the file might already exist and you're
sure you always want to overwrite it, no matter what. You probably
want a lock, too, in case some luser sends two copies in rapid
succession ("newbie just learned to double-click" syndrome in
Netscape's mail editor, for example).

:0
* ^TO_test(_at_)topsecret(_dot_)net
{
        :0 b
        | cat > ~/website/test/mailfile.html
}

OTOH (that's "Off Top Of Head," of course :-)

    :0
    * ^TO_test(_at_)topsecret\(_dot_)net
    * ^X-Header: \/[a-z]+\.html
    {
        LOCKFILE="$HOME/website/test/$MATCH.$LOCKEXT"

        :0
        * test -f "$HOME/website/test/$MATCH"
        | ( generate warning reply about file already existing )

        :0b
        "$HOME/website/test/$MATCH"

        LOCKFILE=
    }

If you don't want to protect yourself against two writes to the same
file (LOCKFILE and test stuff), you should at least use a lock on the
writing recipe, in order to have any duplicates written to the file in
order, rather than garbinterspledersed.

Standard warnings about users asking for "../../../../../vmunix" and
stuff like that apply. (The above recipe accepts only purely
alphabetic names, not even underscored_names.html.)

Having gotten this far, you could take a look at what's available for
ftp-by-mail servers. I think I have links to a few (indirectly --
check out Alan Stebbens' Procmail library, for example) on my Procmail
Links page at <http://www.iki.fi/~era/procmail/links.html>

Hope this helps,

/* era */

-- 
Defin-i-t-e-ly. Sep-a-r-a-te. Gram-m-a-r.  <http://www.iki.fi/~era/>
 * Enjoy receiving spam? Register at <http://www.iki.fi/~era/spam.html>

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