-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1
In article 4D529B28.7030703@vyznev.net, Ilmari Karonen nospam@vyznev.net wrote:
On 02/09/2011 03:22 AM, River Tarnell wrote:
Or, if you only wanted to receive output on failure:
#! /bin/ksh f=$(mktemp) trap "rm -f $f" 0 /path/to/mytool>$f 2>&1 ||<$f mailx -s "Tool output" $LOGNAME
Just out of curiosity... is there a particular reason for the -f switch to rm here, or are you just trying to be extra sure the tempfile gets deleted?
Because:
* Without -f, rm behaves differently depending on whether the script is run from an interactive terminal or not, so I always use -f to get consistent behaviour; and
* It doesn't matter if the file was already deleted, so I don't want an error message if rm fails.
- river.