From f08a9b032caf23e9e40a5a8efd52eea2140aaaeb Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Sat, 28 Mar 2009 10:25:28 +0100 Subject: Added check_ping function --- etc/functions/check_ping | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 etc/functions/check_ping (limited to 'etc/functions') diff --git a/etc/functions/check_ping b/etc/functions/check_ping new file mode 100644 index 0000000..80ea8ea --- /dev/null +++ b/etc/functions/check_ping @@ -0,0 +1,20 @@ +## vim:ft=zsh +## check_ping -return true if a host responds to ICMP echo requests +typeset -i ipv6 ret + +while [[ $1 == -* ]] { + case $1 in + -6) ipv6=1 ;; + esac + shift +} + +typeset dst=$1 +shift + +if ((ipv6)) { + ping6 -c 1 $dst &> /dev/null +} else { + ping -c 1 $dst &> /dev/null +} +return -- cgit v1.2.3