Results 1 to 3 of 3
  1. #1
    rnara is offline Member
    Join Date
    Mar 2016
    Posts
    5
    Rep Power
    0

    Default How to pass variables as parameters to an ant script

    Hi,

    Please let me know how to pass a variable from a shell script to an ant script.

    I'm running the following within a bash shell script and I'm getting the following output. I need to have the variable values displayed in the build output
    =========================
    #!/bin/sh
    server="serv1"
    cluster="clust1"
    /appl/user/ci/ant/bin/ant -f /appl/user1/build.xml -Dserv="$server" -Dclust="$cluster"

    =======================

    build.xml
    ======================
    <?xml version="1.0"?>
    <project name="Hello World Project" default="info">

    <target name="info">
    <echo>server name is $serv</echo>
    <echo>cluster name is $clust</echo>
    </target>

    </project>

    ========================

    Result
    ======
    Buildfile: /appl/user1/build.xml

    info:
    [echo] server name is $server
    [echo] cluster name is $cluster

    BUILD SUCCESSFUL
    Total time: 0 seconds

  2. #2
    SurfMan's Avatar
    SurfMan is offline Godlike
    Join Date
    Nov 2012
    Location
    The Netherlands
    Posts
    1,991
    Rep Power
    8

    Default Re: How to pass variables as parameters to an ant script

    The variable should use curly braces:
    Java Code:
    <echo>server name is ${serv}</echo>
    <echo>cluster name is ${clust}</echo>
    "It's not fixed until you stop calling the problem weird and you understand what was wrong." - gimbal2 2013

  3. #3
    rnara is offline Member
    Join Date
    Mar 2016
    Posts
    5
    Rep Power
    0

    Default Re: How to pass variables as parameters to an ant script

    Thanks! SurfMan. It worked.

Similar Threads

  1. How do i pass parameters from one page to the other
    By megabull in forum New To Java
    Replies: 10
    Last Post: 09-05-2012, 05:34 AM
  2. pass parameters from jsp to another jsp
    By chathura chaminda in forum JavaServer Pages (JSP) and JSTL
    Replies: 2
    Last Post: 03-21-2012, 10:37 AM
  3. How to pass parameters to frames
    By nino23 in forum AWT / Swing
    Replies: 1
    Last Post: 06-29-2011, 09:39 PM
  4. Replies: 5
    Last Post: 11-21-2010, 02:08 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •