On May 22, 2009, at 4:40 PM, Scott Haneda wrote:
On May 22, 2009, at 3:52 PM, David Forrest wrote:
I have searched for "dig return codes" and also looked at the man
page, leading me to nothing definitive.
Does `dig` have return codes that I can use to make some form of
automated tests?
foo=`dig NS example.com @ns2.example.com +short +time=2 +tries=1`
echo $foo
; <<>> DiG 9.4.3-P1 <<>> NS example.com @ns2.example.com +short
+time=2
+tries=1 ;;
global options: printcmd ;;
connection timed out; no servers could be reached
I do not know, nor would I want to have to know, all the possible
return strings I may get back. My needs are simple, I believe any
ANSWER of > 0 I would determine to be true, any timeout of any
form I would determine to be false.
Can anyone point me to docs on return codes, or is this going to
amount to string parsing? If it does, how much deviation on
return messages are there from the various dig versions that have
been released?
Thank you.
my dig (version DiG 9.6.1b1) returns RC 0 on both an answer and a
connection timeout, and would seem to require a string parsing for
a useful branch. F9 64 system.
Would you mind sharing with me how you tested that return value? I
am not seeing that bahavior at all, I get a true return for
anything. I have not been able to get false as of yet.
0 is true (success), anything else is false (error). This allows for
multiple error codes and is standard for Unix commands.
To see the result of a command, use "echo $?" immediately afterward.
For example:
# foo=`dig`; echo $?
0
# foo=`dig @192.0.2.1`; echo $?
9
# foo=`dig @invalid.name`; echo $?
10
Those results come from dig version 9.4.3-P1. In the second example,
there is no host at the specified address. In the third example, the
name given for the server to query is invalid.
Chris Buxton
Professional Services
Men & Mice
_______________________________________________
bind-users mailing list
[email protected]
https://lists.isc.org/mailman/listinfo/bind-users