That dude Hatcher writes in his Ant book and his website two almost the
same, but different ways to grab the hostname:
--------------
Identifying the local host
We identify the local host by looking at the standard environment variables:
<property environment="env"/>
<property name="env.HOSTNAME" value="${env.COMPUTERNAME}"/>
<property name="hostname" value="${env.HOSTNAME}"/>
This extracts the hostname from both the Windows NT and the Unix environment
variables. Apparently, it does not work on Mac OS X; non-Unix platforms are
an unknown. We have a <hostname> task in the pipeline that will work across all
platforms, but it came in too late for Ant 1.5.
Hmmm....I would think that which machines it works on is more of a
factor of the parent shell which sets these environment variables.
Tcsh and Csh (default on the MacOSX) seem to use the environment
variable $HOST, whereas I think the $HOSTNAME is a bash thing.
You could always get Ant to "shell out" and run the 'hostname' command.
--------------
--------------
http://www.ehatchersolutions.com/JavaDevWithAnt/ant.html
!-- Capture the computer name in a cross-platform manner -->
<property name="env.COMPUTERNAME" value="${env.HOSTNAME}"/>
The env.COMPUTERNAME property line is an interesting trick to get the host
name of the machine running the build in a cross-platform manner. Windows
machines use the COMPUTERNAME environment variable while 'nix platforms use
HOSTNAME (except Mac OS X, through version 10.2.3 at least, *arg*).
--------------
Which is it? Both work? Neither?
And that <hostname> task apparently hasn't materialized yet (unless I missed
it on the ant site.)
Timo
