1 |
rabit |
1.1 |
#!/bin/sh |
2 |
|
|
#--------------------------------------------------------------------- |
3 |
|
|
A='getns' |
4 |
|
|
B='rabit@netfrag.org, 11.10.2004 - 12.10.2004' |
5 |
|
|
C="$A - Get nameserver" |
6 |
|
|
I='$Id$' |
7 |
|
|
#--------------------------------------------------------------------- |
8 |
|
|
|
9 |
|
|
NSList='/etc/resolv.conf' |
10 |
|
|
|
11 |
|
|
E='echo -e' |
12 |
|
|
YW="\033[1;33m" |
13 |
|
|
GY="\033[0;37m" |
14 |
|
|
B1="\033[1m" |
15 |
|
|
B0="\033[0m" |
16 |
|
|
|
17 |
|
|
Arg=$1 |
18 |
|
|
case "$Arg" in |
19 |
|
|
(-c) |
20 |
|
|
cat $NSList | grep 'nameserver' | cut -d ' ' -f 1 | wc -w |
21 |
|
|
exit |
22 |
|
|
;; |
23 |
|
|
(-h|--help) |
24 |
|
|
;; |
25 |
|
|
(?*) |
26 |
|
|
if ((Arg>0)); then |
27 |
|
|
#if [ -n "$Arg" ] && ((Arg>0)); then |
28 |
|
|
head -n $1 $NSList | grep 'nameserver' | tail -n 1 | cut -d ' ' -sf2 |
29 |
|
|
exit |
30 |
|
|
fi |
31 |
|
|
;; |
32 |
|
|
esac |
33 |
|
|
|
34 |
|
|
$E "$YW$C$GY\n($B)\n($I)" |
35 |
|
|
$E $B1'Usage:'$B0 |
36 |
|
|
$E ' '$B1$A' <number>'$B0 |
37 |
|
|
$E " Print the $B1<number>${B0}ths nameserver IP from '$B1$NSList$B0'." |
38 |
|
|
$E " If no name servers are available result is empty, if $B1<number>$B0 is greater" |
39 |
|
|
$E " than server entries available, the last one is printed." |
40 |
|
|
$E ' '$B1$A' -c'$B0 |
41 |
|
|
$E " Print the count of name server entries in '$B1$NSList$B0'." |
42 |
|
|
$E ' '$B1$A' [-h|--help]'$B0 |
43 |
|
|
$E " Show this help and exit." |