Solaris equivalent of hostname -f?

Solaris equivalent of hostname -f?

What is the Solaris equivalent of the Linux hostname -f command? On Solaris, when I type hostname, I receive the short name but I need to get the FQDN.

Typing hostname -f sets the short name to be "-f", and the manpage for hostname is pitiful.

Respuesta1

This is likely to work:

perl -mNet::Domain -e 'print Net::Domain::hostfqdn(), "\n"'

but it's not guaranteed. You can view the module source:

perldoc -m Net::Domain

to see how it works (if you know Perl well enough).

Respuesta2

If you are on a system that the DNS knows about, you could try this:

bash-3.00# nslookup `hostname` | grep 'Name:' | awk '{print $2}'
ep60.bar.foo.com

or, as suggested by a commenter, use "host" instead of nslookup:

host $(hostname) | cut -d" " -f1

I tested this successfully on Linux, Solaris, AIX, and HP-UX.

Respuesta3

check-hostname | awk '{ print $NF }'

información relacionada