Discussion:
passing parameters from Ant to Unix Shell script
Animesh Ghosh
2004-09-27 04:36:30 UTC
Permalink
Hi,

I am trying to pass parameters from Ant to Unix shell scripts that
will maintain all environment variables across environments. Can you
pls. pass on a sample build.xml file and a sample shell script which
can accept parameters from the build file. I am familiar with command
line argument passing for Shell scripts but do not know well enough
about Ant scripts. Any help will be much appreciated.
Robert Mark Bram
2004-09-27 04:40:09 UTC
Permalink
Hi Animesh!
Post by Animesh Ghosh
I am trying to pass parameters from Ant to Unix shell scripts that
will maintain all environment variables across environments. Can you
pls. pass on a sample build.xml file and a sample shell script which
can accept parameters from the build file. I am familiar with command
line argument passing for Shell scripts but do not know well enough
about Ant scripts. Any help will be much appreciated.
I asked the same question recently!

<exec executable="bash scripts which can use myVar">
<env key="myVar" value="someValue"/>
</exec>

-- from Stefan Bodewig

or

1. you can use nested <env>s when invoking with <exec>
2. you can create the script from a template and insert the "export"
statements

-- from JanMaterne

Rob
:)
--
Robert Mark Bram
B.Comp.(Systems Development/Business Systems)
B.Net.Comp.(Hons)
Doctor of Philosophy Student

School of Network Computing
Faculty of Information Technology
Monash University
Peninsula Campus
McMahons Rd
Frankston, VIC 3199
AUSTRALIA

Phone: 61 3 9904 4394
Facsimile: 61 3 9904 4124
Email: ***@infotech.monash.edu.au
Robert Mark Bram
2004-09-27 05:41:02 UTC
Permalink
Hi Animesh!
So if I need to add multiple environment properties I can keep on
adding env keys?
Yes.
What if I use parameters instead?
You can use nested <arg> elements to send paramaters to the script, but
this isn't the same as setting an environment variable.
Shall I just use
the $myVar in the Unix script?
Well, if you use nested <arg> you will only be able to use it in the
single script. If you use <env> you can it in scripts called by that too
because it is exported..

Rob
:)
--
Robert Mark Bram
B.Comp.(Systems Development/Business Systems)
B.Net.Comp.(Hons)
Doctor of Philosophy Student

School of Network Computing
Faculty of Information Technology
Monash University
Peninsula Campus
McMahons Rd
Frankston, VIC 3199
AUSTRALIA

Phone: 61 3 9904 4394
Facsimile: 61 3 9904 4124
Email: ***@infotech.monash.edu.au
Loading...