You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Shawn Castrianni <Sh...@halliburton.com> on 2009/05/28 08:27:38 UTC

clone fake environment variables as real ones for exec

I load in my environment variables with:

<property environment="env"/>

I use ant properties throughout my script with the env. prefix so that end users can override them with real environment variables, if they wish.  If those env. prefixed ant properties are not initialized from the real environment variables, I default them inside ant.  This results in fake environment variables that are really just ant properties with an env. prefix.

My problem is if I call an exec task, I would like to pass in all the fake env. variables into that exec task.  Any real environment variables get automatically passed down or inherited by the exec task, so those work fine.  However, the fake env. prefixed ant properties that were not initialized from the real environment and defaulted within ant are not passed down because they are only ant properties.  I would rather not have to specify lots of <env> tags within my exec call just to translate my fake env. prefixed ant properties into real environment variables for the duration of the exec call.  Something like:

<exec executable="whatever" dir="whatever">
                <env key="ENV1" value="${env.ENV1}"/>
                <env key="ENV2" value="${env.ENV2}"/>
                <env key="ENV3" value="${env.ENV3}"/>
</exec

I would prefer to somehow tell ant to select all properties that start with env. prefix and add them to the environment of the exec task.  Is this possible somehow with macros, property selectors, or something else?

---
Shawn Castrianni

----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

Re: clone fake environment variables as real ones for exec

Posted by Dominique Devienne <dd...@gmail.com>.
On Thu, May 28, 2009 at 1:27 AM, Shawn Castrianni
<Sh...@halliburton.com> wrote:
> I would prefer to somehow tell ant to select all properties that start with env. prefix and add them to the environment of the exec task.  Is this possible somehow with macros, property selectors, or something else?

This is something I meant to add, similar to how I added
<syspropertyset> to <java> and <subant>, to have an <envset> with the
same mapper functionality for on-the-fly renaming, but never got
around to do it, sorry. Not difficult to code, since can leverage
PropertySet; would be great if you did it Shawn, should be very easy
for you. --DD

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


Re: AW: clone fake environment variables as real ones for exec

Posted by Eric Fetzer <el...@yahoo.com>.
I was looking at the mapper task.  I didn't fully get it, but I think it could handle what you're looking for.




________________________________
From: "Knuplesch, Juergen" <Ju...@icongmbh.de>
To: Ant Users List <us...@ant.apache.org>
Sent: Thursday, May 28, 2009 2:23:58 AM
Subject: AW: clone fake environment variables as real ones for exec

Hello, 

One way this could work is by wrting your own exec2 task by using the <exec> source and add an argument of your choice that does the trick (an extension of the env argument).

Probably a script (python, etc.) language is also able to set environment variables.
So you could use the script task.

Greetings 

-- 
Jürgen Knuplesch
-----Ursprüngliche Nachricht-----
Von: Shawn Castrianni [mailto:Shawn.Castrianni@halliburton.com] 
Gesendet: Donnerstag, 28. Mai 2009 08:28
An: 'Ant Users List'
Betreff: clone fake environment variables as real ones for exec

I load in my environment variables with:

<property environment="env"/>

I use ant properties throughout my script with the env. prefix so that end users can override them with real environment variables, if they wish.  If those env. prefixed ant properties are not initialized from the real environment variables, I default them inside ant.  This results in fake environment variables that are really just ant properties with an env. prefix.

My problem is if I call an exec task, I would like to pass in all the fake env. variables into that exec task.  Any real environment variables get automatically passed down or inherited by the exec task, so those work fine.  However, the fake env. prefixed ant properties that were not initialized from the real environment and defaulted within ant are not passed down because they are only ant properties.  I would rather not have to specify lots of <env> tags within my exec call just to translate my fake env. prefixed ant properties into real environment variables for the duration of the exec call.  Something like:

<exec executable="whatever" dir="whatever">
                <env key="ENV1" value="${env.ENV1}"/>
                <env key="ENV2" value="${env.ENV2}"/>
                <env key="ENV3" value="${env.ENV3}"/> </exec

I would prefer to somehow tell ant to select all properties that start with env. prefix and add them to the environment of the exec task.  Is this possible somehow with macros, property selectors, or something else?

---
Shawn Castrianni

----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

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


      

AW: clone fake environment variables as real ones for exec

Posted by "Knuplesch, Juergen" <Ju...@icongmbh.de>.
Hello, 

One way this could work is by wrting your own exec2 task by using the <exec> source and add an argument of your choice that does the trick (an extension of the env argument).

Probably a script (python, etc.) language is also able to set environment variables.
So you could use the script task.

Greetings 

-- 
Jürgen Knuplesch
-----Ursprüngliche Nachricht-----
Von: Shawn Castrianni [mailto:Shawn.Castrianni@halliburton.com] 
Gesendet: Donnerstag, 28. Mai 2009 08:28
An: 'Ant Users List'
Betreff: clone fake environment variables as real ones for exec

I load in my environment variables with:

<property environment="env"/>

I use ant properties throughout my script with the env. prefix so that end users can override them with real environment variables, if they wish.  If those env. prefixed ant properties are not initialized from the real environment variables, I default them inside ant.  This results in fake environment variables that are really just ant properties with an env. prefix.

My problem is if I call an exec task, I would like to pass in all the fake env. variables into that exec task.  Any real environment variables get automatically passed down or inherited by the exec task, so those work fine.  However, the fake env. prefixed ant properties that were not initialized from the real environment and defaulted within ant are not passed down because they are only ant properties.  I would rather not have to specify lots of <env> tags within my exec call just to translate my fake env. prefixed ant properties into real environment variables for the duration of the exec call.  Something like:

<exec executable="whatever" dir="whatever">
                <env key="ENV1" value="${env.ENV1}"/>
                <env key="ENV2" value="${env.ENV2}"/>
                <env key="ENV3" value="${env.ENV3}"/> </exec

I would prefer to somehow tell ant to select all properties that start with env. prefix and add them to the environment of the exec task.  Is this possible somehow with macros, property selectors, or something else?

---
Shawn Castrianni

----------------------------------------------------------------------
This e-mail, including any attached files, may contain confidential and privileged information for the sole use of the intended recipient.  Any review, use, distribution, or disclosure by others is strictly prohibited.  If you are not the intended recipient (or authorized to receive information for the intended recipient), please contact the sender by reply e-mail and delete all copies of this message.

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