Ruud H.G. van Tol <rvtol <at> isolution.nl> writes:
si-riesal schreef:
:0
* ^Subject: getresult stuid $STUID passid $PASSID
| echo "USE TEST; \
SELECT * \
FROM login \
WHERE id_student = $STUID \
AND passwd = $PASSID" \
| /usr/local/mysql/bin/mysql -t -n \
> $HOME/mail/"result.txt" ; \
(formail -r ; cat "result.txt") \
| $SENDMAIL -oi -t ; rm -r "result.txt"
I think that you are running the risk that two processes will write to
the same "result.txt".
Maybe you should use something like
RESULT = "result_$$.txt"
and use that variable. The "$$" contains the PID.
Also use lockfile with $$ in the name.
But ideally you would pipe the output of mysql into formail.
:0
* ^Subject: getresult stuid $STUID passid $PASSID
{ MYSQL = `mysql TEST -t -e "SELECT * FROM login
WHERE id_student = $STUID AND passwd = $PASSID"`
:0
* MYSQL ?? [^ ]
| (formail -r ; echo "${NL}${MYSQL}" ) | $SENDMAIL -oi -t
}
(untested)
The second thread again :)
Okay.. its look like that my problem is done, thanx for Ruud H.G. van Tol
<rvtol
<at> isolution.nl> for advice, i really appreciate that :)
but.. the latest recipe would not working in my machine, and i try to make a
change, so .. here is my .procmailrc:
MAILDIR=$HOME/mail
LOGFILE=$MAILDIR/log
:0
* ^Subject: getresult stuid \/[^ ]+
{ STUID = "$MATCH" \
ID = "$STUID" \
MATCH = ''}
:0
* ^Subject: getresult stuid [^ ]+ pass \/[^ ]+
{ PASS = "$MATCH" \
PW = "$MATCH" \
MATCH = "$PASS" }
:0
* ^Subject: getresult stuid \/[^ ]* pass \/[^ ]*
| echo "USE KHS; SELECT * FROM study, login WHERE login.student_id = '$STUID'
AND login.passwd = '$PASS' " | /usr/local/mysql/bin/mysql -t -n > $HOME/mail/
"$STUID" ; (formail -r ; cat "$STUID") $SENDMAIL -oi -t ; rm -r "$STUID"
the script above was completely work.
Thanx to Ruud H.G. van Tol
Regards,
-riesal
____________________________________________________________
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