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 How to execute a grep command 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 "How to execute a grep command from Ant?" Watch "How to execute a grep command from Ant?" New topic
Author

How to execute a grep command from Ant?

Johnson arthur
Greenhorn

Joined: Jul 26, 2012
Posts: 3

Hello,

Can some one please help on how to execute a linux command like grep from ANT ?

Here is the command i want to run (grep = xyz.txt > abc.properties)

Can we use <exec task from ANT ? If so how to use it ?

Can i use something like this ?

<exec dir="${input}" command="grep = xyz.txt > abc.properties"/>

Please suggest!!

Thank you!!
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5836
    
    7

Yes, you want to use the <exec> task. Check out the docs for that task, it will give you some examples on how to invoke apps:
http://ant.apache.org/manual/Tasks/exec.html
Look specifically at the "output" property, that is how you would specify the "abc.properties" in your example.
Look at the <args> nested element, that is how you pass command line option to grep.
Finally, the "executable" property should be set to "grep", not to the full command line.

If you still have problems, feel free to post again, we'll be glad to help.


JBoss In Action
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to execute a grep command from Ant?