Xref: utzoo comp.unix.programmer:169 comp.unix.questions:25942 Path: utzoo!attcan!uunet!samsung!interlan.InterLan.COM!interlan.interlan.com!towfiq From: towfiq@interlan.Interlan.COM (Mark Towfiq) Newsgroups: comp.unix.programmer,comp.unix.questions Subject: Re: Easy way to find hostname/domainname Message-ID: Date: 3 Oct 90 14:38:01 GMT References: <1990Sep28.162012.14325@saukh.rd.jvd.su> Sender: news@interlan.Interlan.COM (No News is BAD News) Organization: Racal InterLan, Inc., Boxborough, MA (1-800-LAN-TALK) Lines: 21 In-Reply-To: nms@saukh.rd.jvd.su's message of 28 Sep 90 16:20:12 GMT Nntp-Posting-Host: slam.interlan.com In article <1990Sep28.162012.14325@saukh.rd.jvd.su> nms@saukh.rd.jvd.su (Nickolay Saukh) writes: I need advice/software to figure out the hostname & domain name for C programs and shell scripts. In C for hostname it seems to be quite easy: [how to get hostname deleted] But how to find domain name? Look at some file with magic name? What the name should be (with portabily issues in mind)? In C, I would do a gethostbyname() to get the FQDN, and then take everything after the first "." to be the domain. The same problem for shell scripts. I know about 'hostname' command in BSD world, 'uuname -l' for SV world (and 'uname' also). So you want the FQDN in a shell script? I do not know of a portable way to do this. You could look for /etc/resolv.conf, or you could look for a program like "host", or "nslookup", and maybe AWK its output?