[Bug 854705] Re: dig returns 0 regardless of result of query
It turns out that the host command will do what you want. jeffs@jeffs-desktop:~$ host www.g00gle.com 8.8.8.8 Using domain server: Name: 8.8.8.8 Address: 8.8.8.8#53 Aliases: Host www.g00gle.com not found: 2(SERVFAIL) jeffs@jeffs-desktop:~$ echo $? 1 <=== jeffs@jeffs-desktop:~$ host www.google.com 8.8.8.8 Using domain server: Name: 8.8.8.8 Address: 8.8.8.8#53 Aliases: www.google.com has address 216.58.216.164 www.google.com has IPv6 address 2607:f8b0:400a:805::1013 jeffs@jeffs-desktop:~$ echo $? 0 jeffs@jeffs-desktop:~$ host www.google.com 10.82.34.123 ;; connection timed out; no servers could be reached jeffs@jeffs-desktop:~$ echo $? 1 jeffs@jeffs-desktop:~$ -- You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to bind9 in Ubuntu. https://bugs.launchpad.net/bugs/854705 Title: dig returns 0 regardless of result of query To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bind9/+bug/854705/+subscriptions -- Ubuntu-server-bugs mailing list Ubuntu-server-bugs@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs
[Bug 854705] Re: dig returns 0 regardless of result of query
[Expired for bind9 (Ubuntu) because there has been no activity for 60 days.] ** Changed in: bind9 (Ubuntu) Status: Incomplete => Expired -- You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to bind9 in Ubuntu. https://bugs.launchpad.net/bugs/854705 Title: dig returns 0 regardless of result of query To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bind9/+bug/854705/+subscriptions -- Ubuntu-server-bugs mailing list Ubuntu-server-bugs@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs
[Bug 854705] Re: dig returns 0 regardless of result of query
You never specified what you want. "Sometimes"??? Is that a specification? For instance, NXDOMAIN is *not* an error. May be you actually want something like: ADDRS=$(dig +short www.google.com); if [ -z "$ADDRS" ]; then echo FAILURE; else echo SUCCESS; fi For another example of testing dig results, see the script in http://www.bortzmeyer.org/files/try-get-zone.sh -- You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to bind9 in Ubuntu. https://bugs.launchpad.net/bugs/854705 Title: dig returns 0 regardless of result of query To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bind9/+bug/854705/+subscriptions -- Ubuntu-server-bugs mailing list Ubuntu-server-bugs@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs
[Bug 854705] Re: dig returns 0 regardless of result of query
It's a work around but I'd still expect dig to return a non-zero number sometimes. -- You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to bind9 in Ubuntu. https://bugs.launchpad.net/bugs/854705 Title: dig returns 0 regardless of result of query To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bind9/+bug/854705/+subscriptions -- Ubuntu-server-bugs mailing list Ubuntu-server-bugs@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs
[Bug 854705] Re: dig returns 0 regardless of result of query
I'm not convinced the exit code can be handled how you want it. A lookup that returns NXDOMAIN was a successful lookup, so IMO shouldn't return an exit code of non-zero. is this not a valid work around for what you want? dig www.google.com | grep NOERROR 1>/dev/null && echo SUCCESS || echo FAILURE ** Changed in: bind9 (Ubuntu) Importance: Undecided => Wishlist ** Changed in: bind9 (Ubuntu) Status: New => Incomplete -- You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to bind9 in Ubuntu. https://bugs.launchpad.net/bugs/854705 Title: dig returns 0 regardless of result of query To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bind9/+bug/854705/+subscriptions -- Ubuntu-server-bugs mailing list Ubuntu-server-bugs@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs
[Bug 854705] Re: dig returns 0 regardless of result of query
I would expect dig to respond in this manner: dig +short www.google.com && echo SUCCESS || echo FAILURE -- You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to bind9 in Ubuntu. https://bugs.launchpad.net/bugs/854705 Title: dig returns 0 regardless of result of query To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bind9/+bug/854705/+subscriptions -- Ubuntu-server-bugs mailing list Ubuntu-server-bugs@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs
[Bug 854705] Re: dig returns 0 regardless of result of query
What do you mean "failed"? NXDOMAIN? SERVFAIL? Timeout? They are very different things. I would strongly object to returning 1 when the answer is NXDOMAIN (the query succeeded). -- You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to bind9 in Ubuntu. https://bugs.launchpad.net/bugs/854705 Title: dig returns 0 regardless of result of query To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bind9/+bug/854705/+subscriptions -- Ubuntu-server-bugs mailing list Ubuntu-server-bugs@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs
[Bug 854705] Re: dig returns 0 regardless of result of query
Sorry it should return 1 instead if the query failed. -- You received this bug notification because you are a member of Ubuntu Server Team, which is subscribed to bind9 in Ubuntu. https://bugs.launchpad.net/bugs/854705 Title: dig returns 0 regardless of result of query To manage notifications about this bug go to: https://bugs.launchpad.net/ubuntu/+source/bind9/+bug/854705/+subscriptions -- Ubuntu-server-bugs mailing list Ubuntu-server-bugs@lists.ubuntu.com Modify settings or unsubscribe at: https://lists.ubuntu.com/mailman/listinfo/ubuntu-server-bugs