#!/bin/bash # FILE: wagon:back/lib/ns_lookup_send # DESCRIPTION: Send nslookup command to DNS master server # USAGE: send [option] cmd # ERRORS: # 3: not found # 4: server down # 5: other nslookup error # 6: nslookup refused source /etc/wagon/config # Ignore SC2068 and leave ${@} unquoted so it can expand if ! res="$(/usr/bin/nslookup ${@} "${DNS_MASTER}")" then exit 5 fi if <<<"${res}" grep ';; .* timed out' then exit 4 elif <<<"${res}" grep "\*\* .*: NXDOMAIN\|\*\*\* .*: No answer" then exit 3 elif <<<"${res}" grep "\*\* .*: REFUSED" then exit 6 else printf '%s' "${res}" fi