Sys::Ho...me::Long(3)

πŸ’– Sys::Ho...me::Long(3) πŸ’–

okay so bestie, you're reading the Sys::Ho...me::Long(3) page from the User Contributed Perl Documentation and honestly? it's giving "i will try literally every conceivable way to get your full hostname" energy πŸ‘‘


✨ NAME ✨

Sys::Hostname::Long β€” try every conceivable way to get the full hostname, no cap 🫢


πŸŽ€ SYNOPSIS πŸŽ€

use Sys::Hostname::Long;
$host_long = hostname_long;

πŸ¦‹ DESCRIPTION πŸ¦‹

So like… how do you get the host's full name in Perl across multiple operating systems (mac, windows, unix* etc)? That's the whole vibe of this module πŸ’…


🌸 DISCUSSION 🌸

Okay so this is the SECOND release of this code β€” it has an improved set of tests and improved interfaces, but ngl it's still often failing to get a full host name 😭 and that is, of course, the exact reason the module was written. Getting full host names accurately on each system is genuinely difficult. On some systems (eg: Linux) it's dependent on the order of the entries in /etc/hosts. main character problems fr fr.

To make it easier to test, there's testall.pl to generate an output list of all methods β€” so even if the logic is incorrect, it may be possible to get the full name πŸ’–

So it attempts, via many methods, to get the system's full name. The Sys::Hostname class is the best and standard way to get the system hostname β€” but it's missing the long hostname. sad but true.

Special thanks to David Sundstrom and Greg Bacon for the original Sys::Hostname 🫢✨


πŸ‘‘ SUPPORT πŸ‘‘

This is the original list of platforms tested:

  • MacOS β€” Macintosh Classic β€” OK
  • Win32 β€” MS Windows (95,98,nt,2000...)
    • 98 β€” OK
  • MacOS X β€” Macintosh 10 β€” OK
    • (other darwin) β€” Probably OK (not tested)
  • Linux β€” Linux UNIX OS β€” OK
    • Sparc β€” OK
  • HPUX β€” H.P. Unix 10? β€” Not Tested
  • Solaris β€” SUN Solaris 7? β€” OK (now)
  • Irix β€” SGI Irix 5? β€” Not Tested
  • FreeBSD β€” FreeBSD β€” OK

A new list has now been compiled of all the operating systems so that information on their success can be individually kept πŸ’…

THIS IS IN NEED OF AN UPDATE AFTER NEXT RELEASE.
  • Acorn β€” Not yet tested
  • AIX β€” Not yet tested
  • Amiga β€” Not yet tested
  • Atari β€” Not yet tested
  • AtheOS β€” Not yet tested
  • BeOS β€” Not yet tested
  • BSD β€” Not yet tested
  • BSD/OS β€” Not yet tested
  • Compaq β€” Not yet tested
  • Cygwin β€” Not yet tested
  • Concurrent β€” Not yet tested
  • DG/UX β€” Not yet tested
  • Digital β€” Not yet tested
  • DEC OSF/1 β€” Not yet tested
  • Digital UNIX β€” Not yet tested
  • DYNIX/ptx β€” Not yet tested
  • EPOC β€” Not yet tested
  • FreeBSD β€” Not yet tested
  • Fujitsu-Siemens β€” Not yet tested
  • Guardian β€” Not yet tested
  • HP β€” Not yet tested
  • HP-UX β€” Not yet tested
  • IBM β€” Not yet tested
  • IRIX β€” Not yet tested - 3rd hand information might be ok
  • Japanese β€” Not yet tested
  • JPerl β€” Not yet tested
  • Linux
    • Debian β€” Not yet tested
    • Gentoo β€” Not yet tested
    • Mandrake β€” Not yet tested
    • Red Hat- Not yet tested
    • Slackware β€” Not yet tested
    • SuSe β€” Not yet tested
    • Yellowdog β€” Not yet tested
  • LynxOS β€” Not yet tested
  • Mac OS β€” Not yet tested
  • Mac OS X β€” OK 20040315 (v1.1)
  • MachTen β€” Not yet tested
  • Minix β€” Not yet tested
  • MinGW β€” Not yet tested
  • MiNT β€” Not yet tested
  • MPE/iX β€” Not yet tested
  • MS-DOS β€” Not yet tested
  • MVS β€” Not yet tested
  • NetBSD β€” Not yet tested
  • NetWare β€” Not yet tested
  • NEWS-OS β€” Not yet tested
  • NextStep β€” Not yet tested
  • Novell β€” Not yet tested
  • NonStop β€” Not yet tested
  • NonStop-UX β€” Not yet tested
  • OpenBSD β€” Not yet tested
  • ODT β€” Not yet tested
  • OpenVMS β€” Not yet tested
  • Open UNIX β€” Not yet tested
  • OS/2 β€” Not yet tested
  • OS/390 β€” Not yet tested
  • OS/400 β€” Not yet tested
  • OSF/1 β€” Not yet tested
  • OSR β€” Not yet tested
  • Plan 9 β€” Not yet tested
  • Pocket PC β€” Not yet tested
  • PowerMAX β€” Not yet tested
  • Psion β€” Not yet tested
  • QNX
    • 4 β€” Not yet tested
    • 6 (Neutrino) β€” Not yet tested
  • Reliant UNIX β€” Not yet tested
  • RISCOS β€” Not yet tested
  • SCO β€” Not yet tested
  • SGI β€” Not yet tested
  • Symbian β€” Not yet tested
  • Sequent β€” Not yet tested
  • Siemens β€” Not yet tested
  • SINIX β€” Not yet tested
  • Solaris β€” Not yet tested
  • SONY β€” Not yet tested
  • Sun β€” Not yet tested
  • Stratus β€” Not yet tested
  • Tandem β€” Not yet tested
  • Tru64 β€” Not yet tested
  • Ultrix β€” Not yet tested
  • UNIX β€” Not yet tested
  • U/WIN β€” Not yet tested
  • Unixware β€” Not yet tested
  • VMS β€” Not yet tested
  • VOS β€” Not yet tested
  • Windows
    • CE β€” Not yet tested
    • 3.1 β€” Not yet tested
    • 95 β€” Not yet tested
    • 98 β€” Not yet tested
    • Me β€” Not yet tested
    • NT β€” Not yet tested
    • 2000 β€” Not yet tested
    • XP β€” Not yet tested
  • z/OS β€” Not yet tested

πŸ’€ KNOWN LIMITATIONS πŸ’€

🐧 Unix

Most unix systems have trouble working out the fully qualified domain name, because it has to be configured somewhere in the system correctly. For example in most linux systems (debian, ?) the fully qualified name should be the first entry next to the ip number in /etc/hosts:

192.168.0.1     fred.somwhere.special   fred

If it's the other way around, it will fail 😭

🍎 Mac

(no notes here β€” that's literally it πŸ™ˆ)


🌈 TODO 🌈

Contributions:

David Dick
Graeme Hart
Piotr Klaban

* Extra code from G
* Dispatch table
* List of all operating systems.

Solaris      * Fall back 2 - TCP with DNS works ok      * Also can read
/etc/defaultdomain file

⭐ SEE ALSO ⭐

  • L<Sys::Hostname>

πŸ’œ AUTHOR πŸ’œ

Originally by Scott Penrose <scottp@dd.com.au>

Contributions: Michiel Beijen <michiel.beijen@gmail.com>


Copyright (c) 2001,2004,2005,2015 Scott Penrose. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page bestie!! πŸŽ€βœ¨ this lil doc ships as part of perl v5.40.2, dated 2024-02-21, and it lives forever at Sys::Ho...me::Long(3) πŸ’…πŸ«Ά mwah

πŸ“¦ where this page comes from