"host" Return Codes

Chris Thompson cet1 at hermes.cam.ac.uk
Sat May 19 23:54:59 UTC 2007


On May 18 2007, Barry Finkel wrote:

>I have a question about the: "host" command - specifically the return 
>code.  Here is the output of two executions - one on Solaris 10 and
>the other on Ubuntu:
>
>     atalanta% uname -a
>     SunOS atalanta.it.anl.gov 5.10 Generic_125100-05 sun4u sparc
>           SUNW,Sun-Fire-V240
>     atalanta% host aaa.anl.gov
>     Host aaa.anl.gov not found: 3(NXDOMAIN)
>     atalanta% echo $status
>     0
>     atalanta% which host  
>     /usr/sbin/host
>     atalanta%
>
>
>     vm20% uname -a
>     Linux vm20.it.anl.gov 2.6.15-28-amd64-k8 #1 SMP PREEMPT
>           Tue Mar 13 20:57:54 UTC 2007 x86_64 GNU/Linux
>     vm20% host aaa.anl.gov
>     Host aaa.anl.gov not found: 3(NXDOMAIN)
>     vm20% echo $status
>     1
>     vm20% which host
>     /usr/bin/host
>     vm20%
>
>Note that Solaris 10 gives a return code of 0, while Ubuntu gives an
>expected return code of 1.  I did not see anything in the BIND 9.3.4
>CHANGES file about host and return codes.  I do not see any string
>within the host executable that tells me the origin of the source.
>
>     atalanta% strings /usr/sbin/host | grep '[0-9]'
[snipped]
>
>From looking at the "strings" output on Ubuntu and comparing with the
>BIND 9.3.4 source I have on another machine, it appears that Ubuntu
>is built from some BIND distribution.  Does anyone know the origin of
>the Solaris 10 "host" source?  I have an application where I want to
>use "host", and I need to have the return code set.

It would appear by comparison with the contemporaneous "dig" that the
Solaris 10 /usr/sbin/host is from 9.2.4. And it does indeed have the
exit code 0 after NXDOMAIN behaviour that you observe.

So, what else is new? It's (almost) never worth agonising about versions
of BIND and its friends bundled with the operating system, whichever
flavour of operating system that is. Build your own. 

-- 
Chris Thompson
Email: cet1 at cam.ac.uk



More information about the bind-users mailing list