You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Olivier Prouvost <ol...@anyware-tech.com> on 2001/03/07 16:09:38 UTC
Getting environment variable on Linux or Windows ?
Hi,
I'm trying to get the 'HOME' environment variable with ant, using linux
and windows.
In fact, I should directly get the user.home value which is defined by
the jvm. Unfortunately, on Windows environment, its value is
c:\Documents And Settings.... and it's not possible to change it easily.
So I would like to get a defined environment variable named 'HOME',
defined in windows user environment.
How to use the property task with environment attribute ??
<property name='HOME' environment="Linux" value="Linux.HOME"/> ???
Does not work.
I put the 'Linux' value for environment like the os value defined for
exec task. Is it right ?
It seems strange, (windows os value is Windows 2000).
Or should it be : <property name='HOME' environment="${os.name}"
value="${os.name}.HOME"/> ??
Where are defined the different 'os' and 'environment' attribute values
?
Thanks
--
--------------------------------------------
Olivier Prouvost Anyware Technologies
Tel : 05 61 00 52 90 Fax : 05 61 00 51 46
Web : http://www.anyware-tech.com
--------------------------------------------
Re: Getting environment variable on Linux or Windows ?
Posted by Stefan Bodewig <bo...@apache.org>.
Olivier Prouvost <ol...@anyware-tech.com> wrote:
> Stefan Bodewig a écrit :
>
>> Olivier Prouvost <ol...@anyware-tech.com> wrote:
>>
>> > On windows I can initialize my HOME value with C:/user/olivier
>> > but it cause problemes when I initialize a classpath value from
>> > this HOME value...
>>
>> How are you trying to do this?
>
> In fact I do that with may be an old notation ! I concat values like
> this :
>
> <property name="lib" value="${Env.HOME}/dev/xxx/lib"/>
> <property name="productClasspath"
> value="${lib}/a.jar:${lib}/b.jar:${lib}/c.jar"/>
>
This should work - if you are running Ant on Windows. On Unix, the
colon will always be treated as a path separator - on Windows it will
be a path separator unless it is the second character of an entry and
the first one is a letter.
Stefan
deleting a directory recursively
Posted by Bryon Day <br...@aws-online.co.uk>.
dear all,
can anyone help me?
I'm trying to use Ant to recursively remove a directory within my project
directory structure. the directory is "_notes" and there are MANY instances
throughout the project.
here is a copy of the xml I'm using:
<target name="clean">
<delete>
<fileset dir="wwwroot" includes="**/_notes/**" />
</delete>
</target>
when run, this just empties the directories but does not remove the
directory itself.
all help appreciated.
cheers,
Bryon.
Re: Getting environment variable on Linux or Windows ?
Posted by Olivier Prouvost <ol...@anyware-tech.com>.
Stefan Bodewig a écrit :
> Olivier Prouvost <ol...@anyware-tech.com> wrote:
>
> > On windows I can initialize my HOME value with C:/user/olivier but
> > it cause problemes when I initialize a classpath value from this
> > HOME value...
>
> How are you trying to do this?
In fact I do that with may be an old notation ! I concat values like
this :
<property name="lib" value="${Env.HOME}/dev/xxx/lib"/>
<property name="productClasspath"
value="${lib}/a.jar:${lib}/b.jar:${lib}/c.jar"/>
I use the ':' separator for jar files. May be the ';' would work ? I'll
try...
In fact I do not use the Path-like Structures to define the classpath
value. It's surely the solution !
In this case, the disk prefix will surely be correctly taken into
account. I'll check it.
Thanks !
--
--------------------------------------------
Olivier Prouvost Anyware Technologies
Tel : 05 61 00 52 90 Fax : 05 61 00 51 46
Web : http://www.anyware-tech.com
--------------------------------------------
Re: Getting environment variable on Linux or Windows ?
Posted by Stefan Bodewig <bo...@apache.org>.
Olivier Prouvost <ol...@anyware-tech.com> wrote:
> On windows I can initialize my HOME value with C:/user/olivier but
> it cause problemes when I initialize a classpath value from this
> HOME value...
How are you trying to do this?
> It works if I remove the 'C:' prefix, but it limites usage in all
> ant files...
Either we've missed something and you've found a bug, or you are
trying to do it the wrong way.
Stefan
Re: Getting environment variable on Linux or Windows ?
Posted by Olivier Prouvost <ol...@anyware-tech.com>.
Ok ! This information was important !! Putting environment value to XXX
and getting XXX.HOME value works well on all environment (windows,
Linux)
That's great !
On windows I can initialize my HOME value with C:/user/olivier but it
cause problemes when I initialize a classpath value from this
HOME value...
It works if I remove the 'C:' prefix, but it limites usage in all ant
files...
How is it possible to deal with this disk prefix ?
Thanks.
Stefan Bodewig a écrit :
> Stefan Bodewig <bo...@apache.org> wrote:
>
> > Linux is a prefix to the name of the properties created from
> > your environment variables.
>
> and has no connection to your OS. You can use any prefix you want.
>
> Stefan
--
--------------------------------------------
Olivier Prouvost Anyware Technologies
Tel : 05 61 00 52 90 Fax : 05 61 00 51 46
Web : http://www.anyware-tech.com
--------------------------------------------
Re: Getting environment variable on Linux or Windows ?
Posted by Stefan Bodewig <bo...@apache.org>.
Stefan Bodewig <bo...@apache.org> wrote:
> Linux is a prefix to the name of the properties created from
> your environment variables.
and has no connection to your OS. You can use any prefix you want.
Stefan
Re: Getting environment variable on Linux or Windows ?
Posted by Stefan Bodewig <bo...@apache.org>.
Olivier Prouvost <ol...@anyware-tech.com> wrote:
> I'm trying to get the 'HOME' environment variable with ant, using
> linux and windows.
> <property name='HOME' environment="Linux" value="Linux.HOME"/> ???
> Does not work.
No, Linux is a prefix to the name of the properties created from your
environment variables. All environment variables will be transformed
into properties at once
<project default="test" basedir=".">
<target name="test">
<property environment="Linux" />
<echo message="${Linux.HOME}" />
</target>
</project>
works:
bodewig@bodewig ~/jakarta/jakarta-ant >ant -f /tmp/env.xml
Buildfile: /tmp/env.xml
test:
[echo] /home/bodewig
BUILD SUCCESSFUL
Total time: 2 seconds
Stefan