如何获得hp-ux机器的完全quallified域名?


0

如何像hostname -f在linux中一样获得HP-UX机器的完全限定域名?

从手册页,hostname命令没有选项。

我可以通过读取/etc/resolv.conf文件来获取fqdn ,但这是正确的方法,还是我必须执行nslookup命令。

bash-4.2# cat /etc/resolv.conf
domain csez.abccor.com
nameserver 192.68.5.11
bash-4.2# cat /etc/resolv.conf | awk '{print $2}' | head -1
csez.abccorp.com

另外,以下方法是否正确?

echo "$(echo `hostname`).$(cat /etc/resolv.conf | awk '{print $2}' | head -1)"

Answers:


1
nslookup "$(hostname)" | awk 'BEGIN {rv=1;} /^Name:/ {print $2; exit rv=0;} END {exit rv;}'

0

另外,以下方法是否正确?

最好使用这个:

echo "$(echo `hostname`).$(grep domain /etc/resolv.conf | awk '{print $2}' | head -1)"
By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.