Kevin Myers <km(_at_)gcom(_dot_)co(_dot_)th> writes:
Is there a way to access the actual exit code returned from running an
external program?
:0w
* ? progname
| do this is exit code=0
| do this if exit code=1
| and do this if exit code=2
| otherwise, do this.
$? contains the return code of the last external program to execute.
You can test it's value in several ways, for example:
:0 w
* ? progname
| do this if exitcode == 0
# save the return code in a testable variable
ret = $?
# Need the 'E' here as ret will contain the return code of
# the action instead of 'progname' if 'progname' succeeded.
:0 E
* ret ?? ^^1^^
| do this if exitcode == 1
:0 E
* ret ?? ^^2^^
| do this if exitcode == 2
:0 E
| otherwise, do this
Here's a way to do it using scoring:
:0 w
* ? progname
| do this if exitcode == 0
:0 E
* $ -$?^0
| program died because of a signal
:0 E
* $$=^0
* 2^0
| do this if exitcode == 1
:0 E
* $$=^0
* 1^0
| do this if exitcode == 2
:0 E
| otherwise, do this
Philip Guenther
_______________________________________________
procmail mailing list
procmail(_at_)lists(_dot_)RWTH-Aachen(_dot_)DE
http://MailMan.RWTH-Aachen.DE/mailman/listinfo/procmail