Which shell is this? Apart from using endif instead of fi the syntax isn't technically wrong for Bourne shell, but definitely ... eerie.
Code:
if ! ping -c 1 www; then
mailx -s subject mail <<__HERE
Body of email message
__HERE
fi
This can be shortened to the slightly more obscure
Code:
ping -c 1 www || mailx -s subject mail <<__HERE
Body of email message
__HERE
If you specifically want to look for "Destination host unreachable" (which I do not recommend at all) the syntax for that would be something like
Code:
case `ping -c 1 www` in *"Destination host unreachable"*) mailx ... ;; esac
or
Code:
if ping -c 1 www 2>&1 | grep "Destination host unreachable" >/dev/null; then
mailx ...
fi
|