How do I use a script's output in an Ant Conditional
ant, build, conditional-statements, java
Solution
The `<exec>` task has `outputproperty`, `errorproperty` and `resultproperty` parameters that allow you to specify property names in which to store command output / errors / result code.
You can then use one (or more) of them in your conditional statement(s):
<exec command="python some-python-script-that-returns-true-or-false-strings-to-stout.py"
outputproperty="myout" resultproperty="myresult"/>
<if>
<equals arg1="${myresult}" arg2="1" />
<then>
<echo message="I did sometheing" />
</then>
<else>
<echo message="I did something else" />
</else>
</if>
Problem
I want to do something like the following ``` <target name="complex-conditional"> <if> <exec command= "python some-python-script-that-returns-true-or-false-strings-to-stout.py/> <then> <echo message="I did sometheing" /> </then> <else> <echo message="I did something else" /> </else> </if> </target> ``` How do I evaluate the result of executing some script inside of an ant conditional?