diff options
author | Daniel Friesel <derf@derf.homelinux.org> | 2009-03-28 10:25:28 +0100 |
---|---|---|
committer | Daniel Friesel <derf@derf.homelinux.org> | 2009-03-28 10:25:28 +0100 |
commit | f08a9b032caf23e9e40a5a8efd52eea2140aaaeb (patch) | |
tree | 4ae8f40666f4fe2b3c1d6a5ef7d95beb67524877 /etc/functions/check_ping | |
parent | 8fbd72a1f8ed2f6d5034e7a469291995dfe1f7c1 (diff) |
Added check_ping function
Diffstat (limited to 'etc/functions/check_ping')
-rw-r--r-- | etc/functions/check_ping | 20 |
1 files changed, 20 insertions, 0 deletions
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 |