Re: [PATCH v2] send-email: try to get fqdn by running hostname --fqdn on Linux and macOS
- From
Julian Swagemakers <julian@swagemakers.org>
- Date
- May 12, 2025, 07:46 UTC
- Message-ID
- <D9U0KAX6KVXK.WCY7YGX2Q0A5@swagemakers.org>
- In-Reply-To
- <PN3PR01MB9597BC2E1B526A11D21BAB24B895A@PN3PR01MB9597.INDPRD01.PROD.OUTLOOK.COM>
On Sat May 10, 2025 at 9:37 AM CEST, Aditya Garg wrote:
> `hostname` is a popular command available on both Linux and macOS. As > per the man-page[1], `hostname --fqdn` command returns the fully > qualified domain name (FQDN) of the system.
There are multiple implementations of the hostname command, and they don't all support `--fqdn`. For example this will not work on Alpine Linux as well as macOS.
macOS:
$ hostname --fqdn
hostname: illegal option -- -
usage: hostname [-f] [-s | -d] [name-of-host]Alpine:
$ hostname --fqdn
hostname: unrecognized option: fqdn
BusyBox v1.37.0 (2025-01-17 18:12:01 UTC) multi-call binary.Usage: hostname [-sidf] [HOSTNAME | -F FILE]
Show or set hostname or DNS domain name
-s Short
-i Addresses for the hostname
-d DNS domain name
-f Fully qualified domain name
-F FILE Use FILE's content as hostnameAll seem to support `-f` though, maybe that would be the better option.
Regards Julian