The ping command returns the exit status 0 when it succeeds and returns non-zero when it fails. Successful means the destination host is reachable, whereas Failure is when the destination host is unreachable.
The return status can be obtained as follows:
$ ping domain -c2 if [ $? -eq0 ]; then echo Successful ; else echo Failure fi