Friday, January 24, 2003

Ant; An Example of The Ant Condition Task

I needed to test the condition code returned by stopping the Apache service so that I could delete the log files. I settled on the following script:
  <property name="apache.service"    value="Apache" />
  <property name=""  value="4" />

  <target name="shutdown_apache" description="stops the Apache service.">
    <exec executable="c:/WINNT/system32/net.exe" resultproperty="apache.stop.resultproperty" outputproperty="apache.stop.outputproperty">
      <arg value="stop" />
      <arg value="${apache.service}" />
    <condition property="apache.not.stopped">
      <equals arg1="${apache.stop.resultproperty}" arg2="2" />
    <antcall target="sleep_apache_stop" />

  <target name="sleep_apache_stop" unless="apache.not.stopped">
    <echo>Sleeping for ${} seconds.</echo>
    <sleep seconds="${}" />
Post a Comment