ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ken Rider" <>
Subject RE: Hostname in ant
Date Wed, 25 Aug 2004 14:40:45 GMT

<project name="test" default="testGetLocalHost">

    <scriptdef name="getLocalHost" language="javascript">
         <attribute name="prefix"/>
             host =;

    <target name="testGetLocalHost">
        <getLocalHost prefix="host."/>
        <echoproperties prefix="host"/>


-----Original Message-----
From: Erik Hatcher [] 
Sent: Wednesday, August 25, 2004 5:41 AM
To: Ant Users List
Subject: Re: Hostname in ant

On Aug 24, 2004, at 4:36 PM, Anderson, Rob (Global Trade) wrote:
> Or if $HOSTNAME is set in your environment, you could use....
> <property environment="env"/>
> and refer to the hostname as "${env.HOSTNAME}".

On Windows, however, HOSTNAME is not set.  Here's a nice trick that 
gets it on 'nix and Windows:

     <property environment="env"/>
     <property name="env.COMPUTERNAME" value="${env.HOSTNAME}"/>

Use ${env.COMPUTERNAME} where the host/computer name is needed.

Good ol' property immutability!


To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message