This week's book giveaways are in the Refactoring and Agile forums.
We're giving away four copies each of Re-engineering Legacy Software and Docker in Action and have the authors on-line!
See this thread and this one for details.
Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Agile forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Cannot run .bat from Ant

 
Rebecca Carpenter
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try as I might, I cannot seem to get this to work. what am I doing wrong here?
<target name="create-user">
<if>
<equals arg1="is.windows" arg2="true" />
<then>
<exec dir="${jboss.home}/bin" failonerror="true" executable="cmd">
<arg value="/c" />
<arg value="add-user.bat" />
<arg value="-a" />
<arg value="username" />
<arg value="password" />
</exec>
</then>
</if>
</target>
 
Roger Sterling
Ranch Hand
Posts: 426
Eclipse IDE Fedora Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Does this work for you ?



If so, then try modifying it one element at a time to get to your desired executable.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What is the problem that you are seeing? I'd hate to give you all kinds of advice about the <if> task if that isn't the issue you are seeing. It would help if you posted the output for the build, or at least for the create-user target.

By the way, you do know that you don't need to use the Ant-contrib <if> task to accomplish your goal, right? That you can do the same using the "if" and "unless" attributes of <target>?
 
Rebecca Carpenter
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am not seeing any errors from running the ant script. It completes successfully. But it does not add the user to the realm.
When I try add-user.bat -a username password from the command line it works as expected. If I try the following, it works fine.
<target name="help">
<exec executable="cmd">
<arg value="/c"/>
<arg value="ant.bat"/>
<arg value="-p"/>
</exec>
</target>
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you seeing any output at all? It still would help if you posted the output for that target. You might also try running ant with the -v option and see if that provides more information. Posting that output would also help.

What I would do next is add some debugging to the add-user.bat script so that I could verify that it was running with the proper settings.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic