How to get fully quallified domain name of a hp-ux machine?

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)"

prasanna

Posted 2013-08-26T07:41:21.263

Reputation: 121

Answers

1

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

Ruslan

Posted 2013-08-26T07:41:21.263

Reputation: 11

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)"

Pernat1y

Posted 2013-08-26T07:41:21.263

Reputation: 1