From 63854847083d4d20ab3ec0afe90fd0a05df1217c Mon Sep 17 00:00:00 2001 From: adam Date: Sun, 12 Mar 2006 23:32:03 +0000 Subject: [PATCH] *** empty log message *** --- bin/pingns | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100755 bin/pingns diff --git a/bin/pingns b/bin/pingns new file mode 100755 index 0000000..5091e2c --- /dev/null +++ b/bin/pingns @@ -0,0 +1,19 @@ +#!/bin/sh + +if [ -n "$1" ]; then + num="$1" + shift +else + num=1 +fi + +ns=$( perl -0777ne 'my @ns = /^ *nameserver +([0-9.]+)/mg; + print $ns['$num' - 1] || ""' \ + /etc/resolv.conf ) + +if [ -z "$ns" ]; then + echo "Could not find nameserver $num in /etc/resolv.conf" >&2 + exit 1 +fi + +ping "$@" "$ns"