I'm trying to set up a service that will feed inputs through a program
and mail the output back to the sender.
The program requires a parameter BASE. The command PROGRAM BASE
acts on a file BASE.EXT1, creating a file BASE.EXT2 and returning
an error code of 0 if successful, and returning a non-zero error code
if unsuccessful.
My present attempt, adapted from a recipe in `man procmailex`
looks like this:
:0 b
* !^FROM_DAEMON
* !^X-Loop: autoreplier(_at_)mail(_dot_)address
|(SHELLSCRIPT)|$SENDMAIL -t
where the file SHELLSCRIPT is a bash shell script containing
cat > TEMPNAME.ext1
if PROGRAM TEMPNAME > TEMPNAME.err ; then
cat TEMPNAME.ext2
else
cat TEMPNAME.err
fi
I'm testing the system by mailing to the autoreplier id from
my own id.
Nothing happens.
Problem 1:
The output of SHELLSCRIPT disappears. If I run it from the bash
prompt it produces the correct stdout file, but when put in the
recipe the output never reaches sendmail -- I tested this by putting
cat > capture.file instead of $SENDMAIL -t and the capture file
stays empty.
Problem 2:
Anyway sendmail probably can't identify any recipients since it
doesn't see the header.
Problem 3:
If two messages come real close together, the second one may ruin
the file TEMPNAME.ext1 before the first one is finished with it.
I suspect that I can use lockfile in some way so the second message
waits until the first one is done, but I really don't understand
how lockfile works.
Should I install smartlist instead of trying to do all this with
procmail?
Dirk