You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@ant.apache.org by Nolan Ring <No...@Sun.COM> on 2003/05/16 16:09:25 UTC

better way to use "equals"?


Hi,

I'm just wondering if there is a better way of doing this.

My goal is to set the properties sqlplus1.prop and sqlplus2.prop and then determine success based on the return value.  This following code works but seems a bit clumsy, especially since I have to check the return status of several additional exec calls.  

Thanks for any feedback.

Nolan


    <target name="cleandb" depends="init">
        <exec executable="sqlplus" resultproperty="sqlplus1.prop">
            <arg line=" ... "/>
        </exec>
        <exec executable="sqlplus" resultproperty="sqlplus2.prop">
            <arg line=" ... "/>
        </exec>
        <condition property="sqlplus1.prop">
          <equals trim="true" arg1="${sqlplus1.prop}"
                              arg2="0"/>
       </condition>
       <if>
          <isset property="sqlplus1.prop"/>
          <then>
              <echo message="SUCCESS" />
          </then>
       <else>
              <echo message="FAILURE in exec call" />
       </else>
       </if> 
        <condition property="sqlplus2.prop">
          <equals trim="true" arg1="${sqlplus2.prop}"
                              arg2="0"/>
       </condition>
       <if>
          <isset property="sqlplus2.prop"/>
          <then>
              <echo message="SUCCESS" />
          </then>
       <else>
              <echo message="FAILURE in exec call" />
       </else>
       </if> 
   </target>