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.
mailfail [--dry-run] RCPT SUBJECT CMD [ARG ...]
mailfail script accepts the following options:
Does not send the email message.
The recipient of the message in a valid format, like
The subject of the message; if it is longer than a word you should guard it with quotes.
The command you want to run and send a mail in case it fails.
The arguments of
CMD, if any.
Here is a typical example, similar to the way it is used in GNUN:
mailfail firstname.lastname@example.org "Bad PO" msgfmt -cv -o /dev/null bg.po
This will check the validity of bg.po with the
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.