diff --git a/README.md b/README.md index 0b4ebe6..37f5b43 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,9 @@ Ping an IP address repeatedly and give a synthesized voice alert when the ping is successful or times out. +PingCheck can be used with Terminal Notifier for OSX +https://github.com/julienXX/terminal-notifier + ## Author Brian Torres-Gil diff --git a/pingcheck b/pingcheck index 8d1da4d..4d4d1ba 100755 --- a/pingcheck +++ b/pingcheck @@ -38,9 +38,19 @@ while [ $count -ne 0 ]; do done if [ $rc -eq 0 ] ; then # Make final determination. - echo "Ping successfull after ${attempts} attempts." - echo `say Ping successfull after ${attempts} attempts.` + message="Ping successfull after ${attempts} attempts." + echo "$message" + if hash terminal-notifier 2>/dev/null; then + terminal-notifier -title "Ping Check" -subtitle "Success" -message "$message" -sound default + else + echo `say Ping successfull after ${attempts} attempts.` + fi else - echo "Timeout after ${attempts} attempts." - echo `say Timeout after ${attempts} attempts.` + message="Timeout after ${attempts} attempts." + echo "$message" + if hash terminal-notifier 2>/dev/null; then + terminal-notifier -title "Ping Check" -subtitle "Timeout" -message "$message" -sound default + else + echo `say Timeout after ${attempts} attempts.` + fi fi