Reputation: 1273
Erlang has inet.gethostname to obtain the hostname:
iex(1)> {:ok, hostname} = :inet.gethostname
{:ok, 'Michaels-MacBook-Pro'}
But how do you obtain the domain name?
Upvotes: 1
Views: 734
Reputation: 9109
:net_adm.dns_hostname(:net_adm.localhost)
seems to do what you want.
Upvotes: 7
Reputation: 1273
It isn't the most elegant solution, but this is the only thing I've found that works so far:
def fqdn do
{fqdn, _exit_status} = System.cmd("hostname", ["-f"])
String.trim(fqdn)
end
Upvotes: 1