Simpler Navigation for Servers and Operating Systems
Completed: a much simpler Servers and Operating Systems section of the Community. We combined many of the older boards, so you won't have to click through so many levels to get at the information you need. Check the consolidated boards here as many sub-forums are now single boards.
Networking
cancel
Showing results for 
Search instead for 
Did you mean: 

nsquery fails to return IP address in a pipe

Bill Hassell
Honored Contributor

nsquery fails to return IP address in a pipe

nsquery returns a null value for Address: when used in a pipe, redirected or assigned to a variable.
Environment: PARISC running HP-UX 11.31

Examples:
 (no pipe = normal behavior) 

# nsquery hosts atl1
Using "files [NOTFOUND=continue UNAVAIL=continue] dns" for the hosts policy.
Searching /etc/hosts for atl1
Hostname: atl1
Aliases: atl1.corp.ad
Address: 10.11.10.200
Switch configuration: Terminates Search


But if the stdout from nsquery is connected using a pipe, redirected to a file or assigned to a variable:

# nsquery hosts atl1 | cat
Using "files [NOTFOUND=continue UNAVAIL=continue] dns" for the hosts policy.
Searching /etc/hosts for atl1
Hostname: atl1
Aliases: atl1.corp.ad
Address: 
Switch configuration: Terminates Search

# nsquery hosts atl1 | grep Address:
Address:

# nsquery hosts atl1 > nsquery.txt
# cat nsquery.txt
Using "files [NOTFOUND=continue UNAVAIL=continue] dns" for the hosts policy. Searching /etc/hosts for atl1 Hostname: atl1 Aliases: atl1.corp.ad Address: Switch configuration: Terminates Search


If a specified resolver method is used (dns in this case), random text may appear in the pipe:

 

# nsquery hosts atl1 dns | cat
Using "dns" for the hosts policy.
Searching dns for atl1
Hostname: atl1.corp.ad
Aliases:
Address
       ã
Switch configuration: Terminates Search

This has been tested on HP-UX 11.00, 11.11, 11.23 and 11.31, PARISC and IA64.

Only PARISC at 11.31 exhibits this behavior consistently.
A tusc trace shows that a write to stdout is correct using a pipe but the IP address is missing after the pipe.

This has been reported to HP and will be addressed in a future patch.
The lab said that it might occur on other versions of HP-UX. 

nsquery is much faster than nslookup in that it does not check DNS server IP and is simpler to try different name resolution methods. However, this error makes it undependable for resolving addresses in scripts.



Bill Hassell, sysadmin