I need to invoke a ant script via shell script. Let us consider the parameters for ant script are a,b,c. how can i pass the parameter for those variables? I must provide the parameters for ant vis invoke the shell script. can anyone help me on this?
In a shell script, you can pass variables as arguments by entering arguments after the script name, for example ./script.sh arg1 arg2 . The shell automatically assigns each argument name to a variable. Arguments are set of characters between spaces added after the script.
Rules and Regulation for Shell Script Parameters Special parameters are used to deliver information to programs by specifying the arguments in the command line. $n can be described by one or more digits, such as $1, $2, $3…., where $1, $2, $3 etc are the arguments to the command.
A script parameter exists only for the duration of the script. Script parameters are reset each time a script is performed. If you want a script parameter to persist while a file is open, you can use a global variable as the script parameter.
Do you mean assigning value to a property from command line? If so, try
-DpropertyName=itsValue
For example,
<project> <target name="hi"> <property name="person" value="world"/> <echo message="Hello ${person}"/> </target> </project>
and then
ant -Dperson="MerryPrankster" hi
yields
[echo] Hello MerryPrankster
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With