procmail
[Top] [All Lists]

How to run script through procmail

1996-08-30 06:20:51

This is a newbie question. If the replies are too elementary for this
list, please email them to me directly.

I have installed procmail on my system (AIX 4 on RS/6000) and have a
simple rc.maillists folder that filters incoming mail from several
lists to separate folders. I use Pine to read mail.

I'm trying to develop a method for receiving text submissions from a
web form, and automatically convert them to HTML and post them. The
following steps are involved:

1. People fill out a web form.
2. The form is automatically converted to email and sent to my account
when they press the "submit" button.
3. When the email arrives in my account, procmail detects that this is
email from the web page by its "Subject" line.
4. Procmail then passes the mail to a shell script, which I have
written.
5. The shell script invokes several other (perl) scripts to
appropriately format the email and create a web page out of it.

All these steps work, except (4).

What I need procmail to do is this:

  - Detect email from the web form based on the subject line (done)
  - Save the UNPROCESSED email (with all headers intact) to a text
    file in my home directory
  - Run a shell script on this file. The script is in my home
    directory.

I put the following recipe in my rc.maillists file:

        :0
        * ^Subject:.*comments2
        {
                :0 c
                >> tfile
        
                :0
                | /homes/home1/pankaj/sc 
        }

What I'm trying to do here is to write the email to a file called
"tfile". AFTER the mail has been saved to "tfile", I want procmail to
run a script called "sc" which is in my home directory.

The script ("sc") is as follows:

        grep 'aaname:' tfile > temp1
        awk '{print $2}' temp1 > temp2
        cat tfile | w.pl `cat temp2`

As you can see, it first uses grep and awk to extract a certain
keyword from the email which is stored in tfile. Next, it pipes tfile
to the "w.pl" script, with the extracted keyword as an argument.

These are the contents of my .procmailrc file:

        #Set on when debugging:
        VERBOSE=on

        #Set the mail directory:
        MAILDIR=$HOME/mail

        #Set directory for procmail logs and rc files:
        PMDIR=$HOME/.procmail

        #Set logfile:
        LOGFILE=$PMDIR/log

        #Some test commands:
        INCLUDERC=$PMDIR/rc.maillists

When I send an email to my account by filling out the web form
described above, the web page is not created, and the following is
reported to the procmail log file:

procmail: Assigning "INCLUDERC=/homes/home1/pankaj/.procmail/rc.maillists"
procmail: Match on "^Subject:.*comments2"
procmail: Skipped "tfile"
procmail: Assigning "LASTFOLDER=>>"
procmail: Opening ">>"
procmail: Acquiring kernel-lock
procmail: [269794] Fri Aug 30 07:48:21 1996
procmail: Assigning "LASTFOLDER=sc"
procmail: [269794] Fri Aug 30 07:48:21 1996
From web_mailer(_at_)uic(_dot_)edu  Fri Aug 30 07:48:19 1996
procmail: Executing "sc"
 Subject: comments2 submission
  Folder: sc                                                               1606
procmail: Notified comsat: "pankaj@:sc"
/bin/sh: sc:  not found

Could someone tell me what I am doing wrong?

Thanks.

+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=
Pankaj Saxena                                      email: 
pankaj(_at_)uic(_dot_)edu
University of Illinois                        http://www.uic.edu/~pankaj
Chicago, IL, USA                 finger u09416(_at_)uicvm(_dot_)uic(_dot_)edu 
for PGP key
+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=


<Prev in Thread] Current Thread [Next in Thread>
  • How to run script through procmail, Pankaj Saxena <=