procmail
[Top] [All Lists]

Re: Email to Bloxsom?

2002-12-23 11:42:15
At 20:12 2002-12-23 +0700, Robert Nicholson wrote:
Here's what I'll use from my filtmail script.

... which isn't procmail. Are you asking us to translate your perl script to something that achieves the same thing within procmail, or are you just on the WRONG list?

Blosxom is a no brains needed weblogging tool that's very simple but effective.

How good fer it. You're still not being clear what it is you are asking for, esp if you seem to already have something that will achieve your goal. Also, when discussing some nonstandard software package, it helps if you provide a URL to information about it, so that everybody doesn't have to go searching for what it is you're talking about and weed through the search results looking for the relevant information. Surely if you use this tool, you have a URL to an official site for it, and that can't be too difficult to include in a message when you're asking others to help you interface with it on a list which has _nothing_ to do with that package?


You do realize that you could invoke this same perl script from procmail like so:

:0:
* ^TO_blog(_at_)elastica\(_dot_)com
| /path/to/your/perlscript.pl

and leave it at that?


use lib "$ENV{HOME}/lib/perl5/site_perl";
use File::Path;

$blogpath = "$ENV{HOME}/www/htdocs/blosxom";

# Something I define for logging purposes
$NL="
"

LOG=${HOME}/yourprocmaillogfile.log

BLOGPATH=${HOME}/www/htdocs/blosxom

if ( $Header{To} =~ /blog\(_at_)elastica(_dot_)com/ ) {

:0
* ^TO_blog(_at_)elastica\(_dot_)com

# strip path and filename
#$Header{Subject} = "path/subdir/subdir2/filename(_dot_)txt(_at_)this is the 
title";

$Header{Subject} =~ /(.*)@(.*)/;
$fullpathname = $1;
$title = $2;
$fullpathname =~ m!(.*)/(.*)!;
$path = $1;
$file = $2;

* Subject:[     ]*\/[^  ].*
{
        SUBJECT=$MATCH

        :0
        * MATCH ?? ^\/[^\(_at_)]+
        {
                FULLPATHNAME=$MATCH
        }

        :0
        * SUBJECT ?? \(_at_)\/.*
        {
                TITLE=$MATCH
        }

        :0
        * FULLPATHNAME ?? /\/[^/]+$
        {
                FILE=$MATCH
        }

        :0
        * FULLPATHNAME ?? ^\/.*/
        {
                # PATH is a system variable.
                # also, unlike the perl code, this INCLUDES the terminating
                # path separator token - it's much easier for us to extract
                # it while maintaining it.
                PATHNAME=$MATCH
        }

#(_at_)dest = split /\//, $path;

$finalpath = $blogpath . '/' . $path;

        FINALPATH=${BLOGPATH}/${PATHNAME}

if (!-d $finalpath) {
   mkpath($finalpath, 755) || die("Cannot make path $finalpath");
}

        # if dir doesn't _already_ exist, create it.
        :0
        * ? test ! -d ${FINALPATH}.
        {
                LOG="Creating ${FINALPATH}$NL"

                :Wic
                * ! FINALPATH ?? ^^^^
                | mkdir -p $FINALPATH

                :0E
                {
                        LOG="Cannot make path $FINALPATH$NL"
                }
        }

# output to file make sure title is the first line
if (!-f "$finalpath/$file") {
   open(BLOG,">$finalpath/$file");
   print BLOG $title;
# output body to rest of file
   print BLOG "\n";
   print BLOG $Body;
   close(BLOG);
}

        # yea, I could use gnu extensions in the echo, but this is more
        # generic.

        # one must wonder why the protection against overrwriting a file
        # -- why not just _concatenate_ ?  Lose the condition line, and
        # change the redir (>) to an appending redir (>>).

        :0b:$FINALPATH$FILE$LOCKEXT
        * ? test ! -f ${FINALPATH}${FILE}
        | ( echo "$TITLE" ; echo ; cat - ) > $FINALPATH$FILE

        # Add a log entry if we don't actually emit the blog.  Note that
        # the message will continue on through to the user mailbox unless
        # we also deliberatley delete it.  Seems sensible to delete it here,
        # but create an mbox archive copy at the top of this recipe (below
        # the address condition).
        :0E
        {
                LOG="Blog entry not added - file exists!$NL"
        }
}

---
 Sean B. Straw / Professional Software Engineering

 Procmail disclaimer: <http://www.professional.org/procmail/disclaimer.html>
 Please DO NOT carbon me on list replies.  I'll get my copy from the list.


_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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