<font size=2 face="sans-serif">From this:</font>
<br><a href=http://partmaps.org/era/procmail/quickref.html><font size=2 face="sans-serif">http://partmaps.org/era/procmail/quickref.html</font></a>
<br><font size=4><b>Test exit code of external program</b></font>
<br><tt><font size=3>* ?&nbsp;</font></tt><font size=3><i>shell command
(pipeline)</i></font>
<br><font size=3>The program gets the current processed message as its
standard input (but is of course free to ignore it); the condition is successful
if the program returns a zero exit code. If the command is a pipeline with
several commands in it, the exit code is whatever the last program in the
pipeline returns (at least on systems worthy of the Unix name).</font>
<br><font size=3>Messages printed to standard error by the pipeline are
displayed in the log.</font>
<br>
<br><font size=2 face="sans-serif">...</font>
<br><font size=5><b>Variables</b></font>
<p><font size=3>Curiously, even those special pseudovariables which are
primarily useful for their associated side effects (</font><tt><font size=3>LOG</font></tt><font size=3>,&nbsp;</font><tt><font size=3>SHIFT</font></tt><font size=3>,
etc) can be referenced, so you can see what the last value you assigned
to them was. This is only marginally useful for most of us, but comes as
a pleasant surprise in situations where this is actually useful.</font>
<br>
<br><font size=2 face="sans-serif">and the return value is in:</font>
<br><font size=2 face="sans-serif">The exit code of a program called up
by Procmail is in&nbsp;$?</font>
<br>
<br><font size=2 face="sans-serif">If you want more, perhaps, this FAQ
suggests:</font>
<br><a href="http://partmaps.org/era/procmail/mini-faq.html"><font size=2 face="sans-serif">http://partmaps.org/era/procmail/mini-faq.html</font></a>
<br><font size=3>More-complicated conditions can also be exit codes of
other shell scripts or programs, or tests against the full body of the
message, or against Procmail variables (Procmail's variables are also exported
to the environment of subprocesses, so they are essentially environment
variables. There are details about this&nbsp;</font><a href="#pass-envar"><font size=3 color=blue><u>later
in this FAQ.)</u></font></a>
<br>
<br><font size=2 face="sans-serif">You can put them in %ENV and have procmail
ref them as $&lt;varname&gt;</font>
<br><font size=3>In the following example, we are grabbing the contents
of the&nbsp;</font><tt><font size=3>Subject:</font></tt><font size=3>&nbsp;header
into the variable&nbsp;</font><tt><font size=3>SUBJECT</font></tt><font size=3>,
and then pass that in as the&nbsp;</font><tt><font size=3>-s</font></tt><font size=3>&nbsp;option
of&nbsp;</font><tt><font size=3>our-script</font></tt><font size=3>.</font>
<p><tt><font size=3>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; &nbsp;SUBJECT=`formail -zxSubject:`<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
:0w:<br>
 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
| our-script -s &quot;$SUBJECT&quot; &gt;&gt;output<br>
</font></tt>
<p><font size=2 face="sans-serif"><br>
----------------------<br>
Andy Bach<br>
Systems Mangler<br>
Internet: andy_bach@wiwb.uscourts.gov<br>
Voice: (608) 261-5738; <br>
Cell: (608) 658-1890</font>
<br>
<br><font size=2 face="sans-serif">&quot;A witty saying proves nothing.&quot;</font>
<br><font size=2 face="sans-serif">&nbsp; --Voltaire</font>