Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Pass parameters for a Ant script , which is invoked via shell script?

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?

like image 789
trilawney Avatar asked Jul 21 '11 12:07

trilawney


People also ask

Can you pass variables in shell script?

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.

When would you use parameters in shell scripts?

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.

What are parameters in scripts?

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.


1 Answers

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 
like image 168
merryprankster Avatar answered Oct 02 '22 23:10

merryprankster