How to get a return value from an exec in ant script -


<target name="checkstate">      <exec executable="${app.path}"/> </target> 

in task, executable app return int value indicate state of app. how returned in value in ant script, use value determine behaviors

thanks in advance

use resultproperty , failonerror attributes of exec task, e.g.:

<target name="checkstate">      <exec executable="${app.path}"            resultproperty="app.state"            failonerror="false"/>      <echo message="app state was: ${app.state}" /> </target> 

quoting exec task docs errors , return codes:

by default return code of exec ignored; when set failonerror="true" return code signaling failure (os specific) causes build fail. alternatively, can set resultproperty name of property , have assigned result code (barring immutability, of course).

if attempt start program fails os dependent error code, halts build unless failifexecutionfails set false. can use run program if exists, otherwise nothing.

what error codes mean? well, os dependent. on windows boxes have @ documentation; error code 2 means 'no such program', means not on path. time see such error ant task, not ant bug, configuration problem on machine.


Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -