X-Git-Url: https://iankelling.org/git/?p=automated-distro-installer;a=blobdiff_plain;f=chost;h=616874151a0aa5c087c1c275198eb4134cbc530e;hp=77e17d467b3447468c59b832efbd3da893e59b06;hb=efcfb463ceda4de1d9953da31a2c0737471e5cf8;hpb=1885f9677fdf2bfeac95285cf13a7d60273d096a diff --git a/chost b/chost index 77e17d4..6168741 100755 --- a/chost +++ b/chost @@ -7,6 +7,7 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR host=$1 -addr=$(getent hosts $host | awk '{print $1}') -h=$(getent hosts $addr | awk '{print $2}') +addr=$(host $host | sed -rn 's/^\S+ has address //p;T;q') +h=$(host $addr) +h=${h##* } echo ${h%%.*}