ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chuck Holzwarth <chuck_holzwa...@yahoo.com>
Subject Re: env.COMPUTERNAME not working in linux
Date Tue, 26 Feb 2008 20:50:49 GMT
Maybe I am missing something, but the simplest fix may be just to set an environment variable
named COMPUTERNAME during login on the Unix/Linux system and it will be available to env.


Sometimes things get more complicated than is necessary...
 

Chuck Holzwarth


----- Original Message ----
From: David Weintraub <qazwart@gmail.com>
To: Ant Users List <user@ant.apache.org>
Sent: Tuesday, February 26, 2008 2:53:25 PM
Subject: Re: env.COMPUTERNAME not working in linux


There 
really 
isn't 
a 
standard 
environment 
variable 
name 
for 
storing
the 
system 
name 
on 
the 
various 
flavors 
of 
Unix. 
This 
is 
usually 
set
when 
users 
log 
in. 
Some 
shells 
do 
set 
the 
environment 
variable
HOSTNAME, 
but 
not 
all. 
Even 
on 
Windows, 
the 
environment 
variable
COMPUTERNAME 
cannot 
be 
trusted 
because 
it 
can 
changed 
by 
the 
user.

On 
Linux, 
the 
environment 
variable 
HOSTNAME 
is 
set 
by 
the 
default
shell 
(BASH), 
but 
not 
by 
other 
shells 
like 
Bourne, 
Csh, 
or 
Kornshell.
You 
could 
simply 
make 
it 
a 
policy 
that 
HOSTNAME 
should 
be 
set 
on 
Unix
logins 
in 
order 
for 
your 
build 
to 
work.

This 
will 
find 
the 
hostname 
whether 
it 
is 
set 
in 
COMPUTERNAME 
(as 
on
Windows) 
or 
HOSTNAME 
(as 
normally 
done 
on 
Linux/Unix):

<target 
name="getname">
  
  
  
  
<property 
environment="env"/>
  
  
  
  
<condition 
property="hostname" 
value="${env.HOSTNAME}">
  
  
  
  
  
  
<isset 
property="env.HOSTNAME"/>
  
  
  
  
</condition>
  
  
  
  
<condition 
property="hostname" 
value="${env.COMPUTERNAME}">
  
  
  
  
  
  
<isset 
property="env.COMPUTERNAME"/>
  
  
  
  
</condition>
  
  
  
  
<fail 
unless="hostname"
  
  
  
  
  
  
message="You 
must 
set 
the 
environment 
variable 
HOSTNAME 
or
COMPUTERNAME 
to 
use 
this 
build 
script"/>
  
  
  
  
<echo 
message="The 
computer's 
name 
is 
&quot;${hostname}&quot;/>
</target>


On 
Tue, 
Feb 
26, 
2008 
at 
9:09 
AM, 
Ramu 
Sethu 
<sramhu@yahoo.co.in> 
wrote:
> 
Hi
>
>  
We 
have 
a 
build 
script 
which 
runs 
in 
both 
windows 
and 
Linux 
m/c. 
Recently 
i
>  
added 
property 
to 
print 
the 
computer 
name 
of 
the 
m/c 
in 
which 
the 
script
>  
runs.
>
>  
In 
windows 
everything 
is 
fine. 
Ant 
sets 
the 
property  
to 
the 
hostname 
in
>  
windows. 
But 
in 
Linux 
it 
prints 
the 
hostname 
like 
"${env.COMPUTERNAME}".
>  
Value 
is 
not 
printed.
>
>  
Is 
COMPUTERNAME 
only 
for 
windows? 
Is 
there 
any 
workaround 
to 
print 
the
>  
hostname(Linux)?
>
>  
We 
don't 
make 
any 
changes 
in 
the 
ant 
script 
when 
running 
in 
Linux.
>
>  
--
>  
Thank 
you
>  
Ramu 
S
>



-- 
--
David 
Weintraub
qazwart@gmail.com

---------------------------------------------------------------------
To 
unsubscribe, 
e-mail: 
user-unsubscribe@ant.apache.org
For 
additional 
commands, 
e-mail: 
user-help@ant.apache.org







      ____________________________________________________________________________________
Be a better friend, newshound, and 
know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ


Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message