File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Ant, Maven and Other Build Tools and the fly likes Cannot run .bat from Ant Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » Ant, Maven and Other Build Tools
Bookmark "Cannot run .bat from Ant" Watch "Cannot run .bat from Ant" New topic
Author

Cannot run .bat from Ant

Rebecca Carpenter
Greenhorn

Joined: Mar 28, 2014
Posts: 2
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

Joined: Apr 06, 2012
Posts: 426

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

Joined: May 14, 2008
Posts: 5845
    
    7

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>?


JBoss In Action
Rebecca Carpenter
Greenhorn

Joined: Mar 28, 2014
Posts: 2
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

Joined: May 14, 2008
Posts: 5845
    
    7

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Cannot run .bat from Ant