Darin Stanchfield <darin(_at_)ktb(_dot_)net> writes:
I run into a problem when I try to check for a file. Here's what I have...
:0 afh
* ? test -f $MAILDIR/$INFO
| cat - $MAILDIR/$INFO 2>&1 | $SENDMAIL -oi -t
You probably don't want the 'a' flag on this recipe. That would make it
depend on the previous recipe (which is...?). I don't think you want the
'f' flag either (what do you want the stdout of sendmail for?) as it will
make procmail continue even on success (with a much reduced message header).
You may want the 'w' flag instead in case sendmail crashes and burns.
Finally, you're forgetting to reverse the header to form the return
headers.
:0 hw
# procmail has already chdir'ed to $MAILDIR, just go relative
* ? test -f $INFO
| formail -r | cat - $INFO | $SENDMAIL -oi -t
:0 efhw
| formail -ri "Subject: Error!"
:0 afh
| cat - $MAILDIR/bad 2>&1 | $SENDMAIL -oi -t
The second shouldn't have the 'f' flag again. I will note that you do
use the 'e' and 'a' flags correctly here.
That said (;-)), there some reason for separating these two? It seems
reasonable to just say:
:0 eh
| formail -ri "Subject: Error!" | cat - bad | $SENDMAIL -oi -t
I am trying to make it catch the error if there is no such file, and send a
different message, "bad." But it doesn't seem to work. Any help would be
appreciated! I am a newbie to procmail.
Just remember that the 'f' flags is only used if you want the *output*
of the command you're running.
Philip Guenther
----------------------------------------------------------------
Philip Guenther UNIX Systems and Network Administrator
Internet: guenther(_at_)gac(_dot_)edu Phonenet: (507) 933-7596
Gustavus Adolphus College St. Peter, MN 56082-1498
Source code never lies (it just misleads). (Programming by Purloined Letter?)