This is a helper script that runs a command, and mails the output of that command in case it exits with a non-zero exit status. mailfail depends on GNU Mailutils, or a compatible implementation, such as BSD's mailx.
Usage:
mailfail [--dry-run] RCPT SUBJECT CMD [ARG ...]
The mailfail script accepts the following options:
someone@somehost.org.
CMD, if any.
Here is a typical example, similar to the way it is used in GNUN:
mailfail translators@example.org "Bad PO" msgfmt -cv -o /dev/null bg.po
This will check the validity of bg.po with the msgfmt program and in case there are errors, a message will be sent to the specified address with `Bad PO' as subject and the error output from msgfmt as body.
mailfail inherits the exit status of the command being run. If an argument is missing, the usage information is printed to the standard output and the exit code is 1.