> From: bill lam
>
> > > > The nicest cross-platform method to finding a computer's hostname
> > > that I know is:
> > > >
> > > > CRLF -.~ shell 'hostname' [ require 'task'
> > >
> > > In that case, I prefer 2!:5 IFUNIX{::'COMPUTERNAME';'HOSTNAME'
> > >
> >
> > The trouble is that it doesn't work for me on Linux (Ubuntu)! Does my
> method work on your flavour?
>
> the hostname for debian (also likely ubuntu) is stored in the
> /etc/hostname
> what will be the outout of
> cat /etc/hostname
>
> if there is no such file or its content is empty, try
> sudo -e /etc/hostname
>
> and write the hostname of your choice.
>
> Your method need to shell an external program to do what can be done
> by J native command. over-skilled ;-)
Yes the hostname is stored in that file on Ubuntu.
So I could read that file to get the hostname:
1!:1 <'/etc/hostname'
Actually on Linux, shell just calls spawn which is 2!:0 - a foreign conjunction
just like 2!:5 !!! I'm not sure if any of the solutions could be called native
J commands?
Is the hostname stored in /etc/hostname for all Linux flavours? Mac?
Even if it was, I think I'd prefer a simple cross-platform solution to one that
requires me to detect the OS and write different solutions for each.
Over-verbose ;-)
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm