0

How to get full qualified domain name of a HP-UX machine as like of hostname -f in linux?

From man pages, hostname command has no options.

I could get fqdn by reading the /etc/resolv.conf file, but is it the correct way to do, or do i have to execute a nslookup command.

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

Also, is the below method is correct ?

echo "$(echo `hostname`).$(cat /etc/resolv.conf | awk '{print $2}' | head -1)"
1
nslookup "$(hostname)" | awk 'BEGIN {rv=1;} /^Name:/ {print $2; exit rv=0;} END {exit rv;}'
0

Also, is the below method is correct ?

Better to use this one:

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.