wood burning stoves 2.0*
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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: 5812
    
    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
 
jQuery in Action, 2nd edition
 
subject: How to execute a grep command from Ant?
 
Similar Threads
Ant task for user interactive input for shell command execution
Running UNIX command from Java
Using Unix "grep" command in java...
multiple greps within on exec statement?
named character classes in grep