dig return values
Stephane Bortzmeyer
bortzmeyer at nic.fr
Tue May 26 13:19:10 UTC 2009
On Fri, May 22, 2009 at 03:15:56PM -0700,
Scott Haneda <talklists at newgeo.com> wrote
a message of 32 lines which said:
> Does `dig` have return codes that I can use to make some form of
> automated tests?
Not for everything.
% dig +short SOA dummy.example && echo Success
Success
% dig +short @192.168.42.42 SOA dummy.example && echo Success
;; connection timed out; no servers could be reached
% dig @a.nic.fr AXFR dummy.example && echo Success
; <<>> DiG 9.5.1-P1 <<>> @a.nic.fr AXFR dummy.example
; (2 servers found)
;; global options: printcmd
; Transfer failed.
Success
So, some errors are detected but not all.
> 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.
Yes, but what about an answer of NOERROR,ANCOUNT=0, for instance:
dig @a.nic.fr A www.google.fr
Is it an error or not?
> Can anyone point me to docs on return codes, or is this going to amount
> to string parsing?
I do string parsing. As an example, see the script in
<http://www.bortzmeyer.org/recuperer-zone-dns.html> (the text is in
french but the comments in the script are in english).
if ! egrep "Transfer failed|connection timed out|Name or service not known|connection refused|network unreachable|host unreachable|communications error" $tmp > /dev/null; then
...
More information about the bind-users
mailing list