#!/bin/ksh
for service in TaskControllerService StreamControllerService
do
if /usr/jdk/instances/jdk1.6.0/bin/sparcv9/jps | /usr/sfw/bin/ggrep -q "$service"
then
print "$service online"
else
print "$service offline"
fi
done > mail_body
mailx -s "Subject" user@domain.com < mail_body
If you don't have ggrep replace that line with:
if /usr/jdk/latest/bin/sparcv9/jps | grep "$service" 1>/dev/null 2>/dev/null
You don't need the GNU utilities version of grep to use the -q option. It has been in the formal standards for more than two decades and in the SVID and X/Open Portability Guides quite a while before there were formal standards for UNIX and UNIX-like system utilities.
It is there in /usr/xpg4/bin/grep and /usr/xpg6/bin/grep. In theory, -q support should have been added to /usr/bin/grep when /usr/xpg4/bin/grep was created (since adding that option would not break any correct use of grep before that option was added), but that didn't always happen.