procmail
[Top] [All Lists]

problem with double $MATCH

2006-05-08 12:57:33
This is my 1st post to this newsgroup.
Actually.. i've tried to make this post as clean as possible, and forgive for
my bad english, iam indonesian.

okay.. this is my problem.

Iam doing my homework to send back a database query result via e-mail using 
procmail. The database that i used is MySQL 5.0.16 running on FreeBSD 5.4 and 
procmail 3.22.
The 1st code should be like this:

--.procmailrc file--
MAILDIR=$HOME/mail
LOGFILE=$HOME/mail/log

:0
* ^Subject: getresult stuid \/[^ ]* 
| echo "USE TEST; SELECT student_id FROM TEST WHERE student_id=$MATCH" | /usr/
local/mysql/bin/mysql -t  > $HOME/mail/result.txt | formail -rA "X-Loop: 
admin(_at_)centurion(_dot_)org" | cat - result.txt 2>&1) | $SENDMAIL -oi -t

--END--

The script above may result like this in reply mail
STUDENT_ID   PASSWD
RIESAL01     RIESAL01
ISITTRUE     IAMNOTSURE

If i want to use SQL selection like "USE TEST; SELECT * FROM TEST WHERE 
student_id=$MATCH and passwd=$MATCH, i try to use the procmail script like this:

--.procmailrc file--
MAILDIR=$HOME/mail
LOGFILE=$HOME/mail/log

:0
* ^Subject: getresult stuid \/[^ ]* passid \/[^ ]*
| echo "USE TEST; SELECT student_id FROM TEST WHERE student_id=$MATCH" and 
passid=$MATCH | /usr/local/mysql/bin/mysql -t  > $HOME/mail/result.txt | 
formail 
-rA "X-Loop: admin(_at_)centurion(_dot_)org" | cat - result.txt 2>&1) | 
$SENDMAIL -oi -t

--END--

The 2nd script only works fine if passid = student_id, like this:

mail-v admin(_at_)centurion(_dot_)org
Subject: getresult stuid RIESAL01 passid RIESAL01

but if i try this one, the result may wrong

mail-v admin(_at_)centurion(_dot_)org
Subject: getresult stuid ISITTRUE passid IAMNOTSURE

can somebody tell me how to make a better script so i can use different passid 
and get true result?

thanx..


regards,


-riesal <riesal(_at_)gmail(_dot_)com>


____________________________________________________________
procmail mailing list   Procmail homepage: http://www.procmail.org/
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail

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