Chris Green
2021-Feb-08 09:36 UTC
[openssh-commits] [openssh] 02/02: upstream: hostname is not specified by POSIX but uname -n is, so use
On Sun, Feb 07, 2021 at 03:43:24PM -0700, Bob Proulx wrote:> Tim Rice wrote: > > > -HOST=`hostname | cut -f1 -d.` > > > -HOSTNAME=`hostname` > > > +HOST=`uname -n | cut -f1 -d.` > > > +HOSTNAME=`uname -n` > > > > This may not work as intended. > > .... > > tim at server01-UnixWare 69% hostname > > server01.int.multitalents.net > > tim at server01-UnixWare 70% uname -n > > server01 > > .... > > I'll just note that on Debian, Ubuntu, other derivatives (such as > Mint, Trisquel...) both the "uname -n" and "hostname" values would > typically be just the short name. It's not just UnixWare... > > rwp at havoc:~$ uname -n > havoc > > rwp at havoc:~$ hostname > havoc >Isn't it just 'hostname -f'? chris$ hostname -f t470.zbmc.eu chris$ hostname t470 -- Chris Green
Bob Proulx
2021-Feb-08 20:54 UTC
[openssh-commits] [openssh] 02/02: upstream: hostname is not specified by POSIX but uname -n is, so use
Chris Green wrote:> Isn't it just 'hostname -f'? > > chris$ hostname -f > t470.zbmc.eu > chris$ hostname > t470The hostname -f option is a "new-ish" Linux specific option. It's not portable. And because it works by doing a reverse DNS lookup it depends upon live network connectivity at that moment working for the network lookup and the results are spotty depending upon how DNS is set up and how many IP addresses are configured on the host. It's problematic. Bob