ant-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alec Fernandez" <>
Subject RE: Execution of windows command in ant's build.xml
Date Wed, 18 Jul 2007 17:25:19 GMT
Excellent clarifications gentleman, many thanks.  

You got me curious so I dug up a working example of quoting that I use.  

Try as I may, I can't seem to escape from the msdos command line processor.  Bill's  enduring
gift to humanity.

      <!-- Exec a command with spawn.  No return code checking possible. -->
      <macrodef name="execSpawnCmd">
         <attribute name="cmd"/>
         <attribute name="cmd.line" default=""/>
         <attribute name="dir" default=""/>
         <attribute name="logdir"/>
         <attribute name="logfile"/>
         <attribute name="callingTarget" default=""/>
            <echo level="verbose" message="execSpawnCmd: cmd = @{cmd}"/>
            <echo level="verbose" message="execSpawnCmd: cmd.line = @{cmd.line}"/>
            <echo level="verbose" message="execSpawnCmd: dir = @{dir}"/>
            <echo level="verbose" message="execSpawnCmd: logdir = @{logdir}"/>
            <echo level="verbose" message="execSpawnCmd: logfile = @{logfile}"/>
            <echo level="verbose" message="execSpawnCmd: callingTarget = @{callingTarget}"/>

            <property name="logfile.fqp" location="@{logdir}/@{logfile}"/>
            <if><equals arg1="${os.localhost.type}" arg2="win"/><then>
               <exec executable="cmd" dir="@{dir}" spawn="true"> 
                  <arg value="/c"/>
                  <arg value="&quot;&quot;@{cmd}&quot; @{cmd.line} &gt;
&quot;${logfile.fqp}&quot; 2&gt;&amp;1&quot;"/>
            </then><elseif><equals arg1="${os.localhost.type}" arg2="unx"/><then>
               <exec executable="@{cmd}" dir="@{dir}" spawn="true">
                  <!-- this doesn't seem to work on unix after all
                  <arg value="@{cmd.line} &gt; ${logfile.fqp} 2&gt;&amp;1"/>
                  <arg value="@{cmd.line}"/>

-----Original Message-----
From: Peter Reilly [] 
Sent: Wednesday, July 18, 2007 12:06 PM
To: Ant Users List
Subject: Re: Execution of windows command in ant's build.xml

On 7/18/07, Jack J. Woehr <> wrote:
> On Jul 18, 2007, at 9:55 AM, Peter Reilly wrote:
> >
> > Remember that a lot of directories have spaces in windows and this, 
> > combined with the multiple layers of quoting and interpretation 
> > (ant, Java, cmd and the other commands) mean that things may not 
> > work as expected.
> Entreprerneurial opportunity here for book, working title, 
> "Weirdnesses using open source software on Windows" :-)
That should be
"Weirdnesses using command line software on Windows"

> --
> Jack J. Woehr
> Director of Development
> Absolute Performance, Inc.
> 303-443-7000 ext. 527

To unsubscribe, e-mail: For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message