On Wednesday 16 February 2005 13:50 CET Aaron Walker wrote:
> Francesco Riosa wrote:
> > Mike Frysinger ha scritto:
> >> On Tuesday 15 February 2005 03:14 pm, Francesco Riosa wrote:
> >>> Is safe / portable use the $(hostname)  inside an ebuild ?
> >[...]
>
> Also keep in mind that Linux is not the only operating system Gentoo runs
> on nowadays.  hostname on Linux is not the same as hostname on BSD (which
> by default prints the fully qualified hostname not the short hostname). 
> I believe using 'hostname -s' should produce the same output on both
> operating systems.

But are you sure that 'hostname -s' does the thing you intend on all systems 
Gentoo might run on?

There's an... ummm... let's call it funny bug for example in the Perl module 
Sys::Hostname::Long which uses the command 'hostname --fqdn' to determine 
the box' FQDN.  Unfortunately doesn't the Solaris hostname support any 
switches so the host will be renamed to '--fqdn' when the module is used as 
root and, under certain circumstances, falls back to the hostname command.  
(See [1] if you want to know the whole story.)

If you really need to do this, try something like
  hostname=$(hostname 2>/dev/null)
  hostname=${hostname%%.*}
You might also want to try
  sysctl -n kernel.hostname

Cheers,
Malte

[1] http://bugzilla.spamassassin.org/show_bug.cgi?id=3806

-- 
[SGT] Simon G. Tatham: "How to Report Bugs Effectively"
      <http://www.chiark.greenend.org.uk/~sgtatham/bugs.html>
[ESR] Eric S. Raymond: "How To Ask Questions The Smart Way"
      <http://www.catb.org/~esr/faqs/smart-questions.html>

--
[email protected] mailing list

Reply via email to