You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Josh Lucas <jo...@stonecottage.com> on 2000/09/01 22:26:31 UTC

Access to env variables

I realize that this might be a silly question but can Ant access env
variables which have been set outside of the process?

I know that I can give Ant a properties file which has 'extra'
properties but I would like to use some pre-set variables.

Does this make sense?


josh

Re: Exec arguments, pipes, and I/O redirection...

Posted by Ken Wood <kw...@i2.com>.
Well, I naively assumed that whatever command line was created, pipes
and redirection and all,
was passed to the OS for processing... but, be that as it may,
I tried the suggestion you and Jose made. It works, I'm happy,
thanks!!

Stefan Bodewig wrote:
> 
> >>>>> "KW" == Ken Wood <kw...@i2.com> writes:
> 
>  KW> <exec executable="cat" dir=".">
>  KW>   <arg line="etc/jsm.properties | sed -f tools/jsmprops_sedscriptfile > application/server/log/jsm.properties" />
>  KW> </exec>
> 
> well, | sed ... is not really an arg to cat, is it? I haven't tried it
> but I think
> 
> <exec executable="sh" dir=".">
>   <arg value="-c" />
>   <arg value="cat etc/jsm.properties | sed -f tools/jsmprops_sedscriptfile > application/server/log/jsm.properties" />
> </exec>

Re: Exec arguments, pipes, and I/O redirection...

Posted by Stefan Bodewig <bo...@bost.de>.
>>>>> "KW" == Ken Wood <kw...@i2.com> writes:

 KW> <exec executable="cat" dir=".">
 KW>   <arg line="etc/jsm.properties | sed -f tools/jsmprops_sedscriptfile > application/server/log/jsm.properties" /> 
 KW> </exec>

well, | sed ... is not really an arg to cat, is it? I haven't tried it
but I think

<exec executable="sh" dir=".">
  <arg value="-c" />
  <arg value="cat etc/jsm.properties | sed -f tools/jsmprops_sedscriptfile > application/server/log/jsm.properties" /> 
</exec>

should work.

Stefan

Exec arguments, pipes, and I/O redirection...

Posted by Ken Wood <kw...@i2.com>.
I guess I'm confused.

I'm doing
  <exec executable="cat"
        dir=".">
        <arg line="etc/jsm.properties | sed -f
tools/jsmprops_sedscriptfile > application/server/log/jsm.properties" /> 
  </exec>

Ant DOES 'cat etc/jsm.properties" but it barfs on the rest, because
it apparently wants to interpret every token on the arg list as files:

     [exec] cat: cannot open |
     [exec] cat: cannot open sed
     [exec] cat: cannot open -f
     [exec] cat: cannot open >

This example is trivial, but more generally it is quite common on Unix
to execute a command and pipe the output through one or more programs,
and
sometimes redirect the output. In this case, we are creating a new
file from a template using some regular expression pattern matching
and replacements....

How do I uses pipes and IO re-direction in an 'exec' ???