You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Luis Andrei Cobo <lc...@cover-all.com> on 2002/12/12 17:03:01 UTC

Localhost name

Is there a way, in Ant, without specifying some startup variable or hard
coding a property, to get the machine name for localhost that the buld
script is running on?

Luis Andrei Cobo
lcobo@cover-all.com
(201) 794-2862
Cubby 3330




--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Localhost name

Posted by Adam Hardy <ad...@cyberspaceroad.com>.
How about for Linux:

<exec executable="uname" outputproperty="hostname">
   <arg line="-a"/>
</exec>
<echo message="${hostname}"/>


OK, now you tell me how I can echo the content of a classpath I just 
compiled, for debug purposes?

Thanks
Adam




Luis Andrei Cobo wrote:

> Is there a way, in Ant, without specifying some startup variable or hard
> coding a property, to get the machine name for localhost that the buld
> script is running on?
>
> Luis Andrei Cobo
> lcobo@cover-all.com
> (201) 794-2862
> Cubby 3330
>
>
>
>
> --
> To unsubscribe, e-mail:
> For additional commands, e-mail:
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Localhost name and other uses

Posted by George Spalding <ge...@yahoo.com>.
I think you also had a <hostname> task in there. 
Thats the one I adpoted. 

It's actually quite convenient to have props that differ from host to
host and operating sys in prop-files named
ant.${the.hostname}.properties
ant.${the.os}.properties
in init just <propertyfile/> them into ant.

 --- Steve Loughran <st...@iseran.com> wrote: 
> there is also a <localhost> task in ant's CVS, under
> proposal/sandbox/httptasks; we should move it in to the main source
> for
> 1.6...I was also thinking of adding an <nslookup> to set a property
> with an
> ipaddr/hostname if the target was lookup-able
> 
> ----- Original Message -----
> From: "Vilya Harvey" <vi...@digitalsteps.com>
> To: "Ant Users List" <an...@jakarta.apache.org>
> Sent: Thursday, December 12, 2002 08:37
> Subject: Re: Localhost name
> 
> 
> > Where I work, we couldn't find a way to do this. So we
> implemented our own
> > task to do it for us. The implementation itself was trivial (just
> call
> > InetAddress.getLocalHost().getHostName() in the execute() method
> and store
> > it in a user-specified property), but I can see about making it
> available
> if
> > you (or anyone else) is interested.
> >
> > Vil.
> > --
> > Vilya Harvey, Consultant
> > vilya.harvey@digitalsteps.com                 / digital steps /
> > (W) +44 (0)1483 469 480
> > (M) +44 (0)7816 678 457                
> http://www.digitalsteps.com/
> >
> > --Disclaimer--
> >
> > This e-mail and any attachments may be confidential and/or
> legally
> > privileged. If you have received this email and you are not a
> named
> > addressee, please inform the sender at Digital Steps Ltd by phone
> on
> > +44 (0)1483 469 480 or by reply email and then delete the email
> from
> > your system. If you are not a named addressee you must not use,
> > disclose, distribute, copy, print or rely on this email. Although
> > Digital Steps Ltd routinely screens for viruses, addressees
> should
> > check this email and any attachments for viruses. Digital Steps
> Ltd
> > makes no representation or warranty as to the absence of viruses
> in this
> > email or any attachments.
> >
> >
> > ----- Original Message -----
> > From: "Luis Andrei Cobo" <lc...@cover-all.com>
> > To: "Ant Users List (E-mail)" <an...@jakarta.apache.org>
> > Sent: Thursday, December 12, 2002 4:03 PM
> > Subject: Localhost name
> >
> >
> > > Is there a way, in Ant, without specifying some startup
> variable or hard
> > > coding a property, to get the machine name for localhost that
> the buld
> > > script is running on?
> > >
> > > Luis Andrei Cobo
> > > lcobo@cover-all.com
> > > (201) 794-2862
> > > Cubby 3330
> > >
> > >
> > >
> > >
> > > --
> > > To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> > > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> > >
> > >
> >
> >
> > --
> > To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> >
> >
> 
> 
> --
> To unsubscribe, e-mail:  
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>  

=====
-\|/-/|\-\|/-/|\-\|/-/|\-\|/-/|\-\|/-/|\-\|/-
George Spalding
Private:      georgespalding@yahoo.com
Phone:
Mobile: +46 701 849 507
Home:   +46 8 21 36 59
-/|\-\|/-/|\-\|/-/|\-\|/-/|\-\|/-/|\-/|\-\|/-

__________________________________________________
Do You Yahoo!?
Everything you'll ever need on one web page
from News and Sport to Email and Music Charts
http://uk.my.yahoo.com

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Localhost name

Posted by Steve Loughran <st...@iseran.com>.
there is also a <localhost> task in ant's CVS, under
proposal/sandbox/httptasks; we should move it in to the main source for
1.6...I was also thinking of adding an <nslookup> to set a property with an
ipaddr/hostname if the target was lookup-able

----- Original Message -----
From: "Vilya Harvey" <vi...@digitalsteps.com>
To: "Ant Users List" <an...@jakarta.apache.org>
Sent: Thursday, December 12, 2002 08:37
Subject: Re: Localhost name


> Where I work, we couldn't find a way to do this. So we implemented our own
> task to do it for us. The implementation itself was trivial (just call
> InetAddress.getLocalHost().getHostName() in the execute() method and store
> it in a user-specified property), but I can see about making it available
if
> you (or anyone else) is interested.
>
> Vil.
> --
> Vilya Harvey, Consultant
> vilya.harvey@digitalsteps.com                 / digital steps /
> (W) +44 (0)1483 469 480
> (M) +44 (0)7816 678 457                 http://www.digitalsteps.com/
>
> --Disclaimer--
>
> This e-mail and any attachments may be confidential and/or legally
> privileged. If you have received this email and you are not a named
> addressee, please inform the sender at Digital Steps Ltd by phone on
> +44 (0)1483 469 480 or by reply email and then delete the email from
> your system. If you are not a named addressee you must not use,
> disclose, distribute, copy, print or rely on this email. Although
> Digital Steps Ltd routinely screens for viruses, addressees should
> check this email and any attachments for viruses. Digital Steps Ltd
> makes no representation or warranty as to the absence of viruses in this
> email or any attachments.
>
>
> ----- Original Message -----
> From: "Luis Andrei Cobo" <lc...@cover-all.com>
> To: "Ant Users List (E-mail)" <an...@jakarta.apache.org>
> Sent: Thursday, December 12, 2002 4:03 PM
> Subject: Localhost name
>
>
> > Is there a way, in Ant, without specifying some startup variable or hard
> > coding a property, to get the machine name for localhost that the buld
> > script is running on?
> >
> > Luis Andrei Cobo
> > lcobo@cover-all.com
> > (201) 794-2862
> > Cubby 3330
> >
> >
> >
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
> >
> >
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Localhost name

Posted by Michael Kuß <mk...@asdis.de>.
Vilya Harvey wrote:
> Where I work, we couldn't find a way to do this. So we implemented our own
> task to do it for us. The implementation itself was trivial (just call
> InetAddress.getLocalHost().getHostName() in the execute() method and store
> it in a user-specified property), but I can see about making it available if
> you (or anyone else) is interested.

Sounds interesting. But keep in mind that on machines using multiple
hostnames/ip java will only return one (IMHO on Linux it's the first 
entry in the /etc/hosts). That can result in some problems
you cannot track down easily.
It's quite ok to do it that way (I don't have any other idea), but it's 
always good to keep the traps in mind.

Micha







--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Localhost name

Posted by Vilya Harvey <vi...@digitalsteps.com>.
Where I work, we couldn't find a way to do this. So we implemented our own
task to do it for us. The implementation itself was trivial (just call
InetAddress.getLocalHost().getHostName() in the execute() method and store
it in a user-specified property), but I can see about making it available if
you (or anyone else) is interested.

Vil.
--
Vilya Harvey, Consultant
vilya.harvey@digitalsteps.com                 / digital steps /
(W) +44 (0)1483 469 480
(M) +44 (0)7816 678 457                 http://www.digitalsteps.com/

--Disclaimer--

This e-mail and any attachments may be confidential and/or legally
privileged. If you have received this email and you are not a named
addressee, please inform the sender at Digital Steps Ltd by phone on
+44 (0)1483 469 480 or by reply email and then delete the email from
your system. If you are not a named addressee you must not use,
disclose, distribute, copy, print or rely on this email. Although
Digital Steps Ltd routinely screens for viruses, addressees should
check this email and any attachments for viruses. Digital Steps Ltd
makes no representation or warranty as to the absence of viruses in this
email or any attachments.


----- Original Message -----
From: "Luis Andrei Cobo" <lc...@cover-all.com>
To: "Ant Users List (E-mail)" <an...@jakarta.apache.org>
Sent: Thursday, December 12, 2002 4:03 PM
Subject: Localhost name


> Is there a way, in Ant, without specifying some startup variable or hard
> coding a property, to get the machine name for localhost that the buld
> script is running on?
>
> Luis Andrei Cobo
> lcobo@cover-all.com
> (201) 794-2862
> Cubby 3330
>
>
>
>
> --
> To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Localhost name

Posted by Ken Gentle <j....@acm.org>.
This little trick, which I seem to remember stealing from Steve and Erik, 
seems to work well for Windoze and Solaris...

     <!-- Get properties from the environment... -->
     <property environment="env"/>
     <!-- Use 'immutable property' trick to make it cross-platform. -->
     <property name="env.HOSTNAME" value="${env.COMPUTERNAME}"/>


         Ken

At 11:03 AM 12/12/2002 -0500, you wrote:
>Is there a way, in Ant, without specifying some startup variable or hard
>coding a property, to get the machine name for localhost that the buld
>script is running on?
>
>Luis Andrei Cobo
>lcobo@cover-all.com
>(201) 794-2862
>Cubby 3330
>
>
>
>
>--
>To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
>For additional commands, e-mail: <ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>