Executing External Programs

The exec task executes a system command or external program. The attributes for this task appear in Table 7-2.

Table 7-2. The exec task's attributes

Attribute

Description

Required

Default

append

Specifies whether you want to append to output and error files.

No

false

command

Deprecated. Use executable and nested arg elements. Specifies the command you want to run.

Exactly one of command or executable.

 

dir

Specifies the directory where you want to run the command.

No

 

error

Specifies the file where standard error output should be stored.

No

 

errorproperty

Specifies the name of a property where you want to store errors.

No

 

executable

Specifies the command you want to run (without any command-line arguments).

Exactly one of command or executable.

 

failifexecutionfails

Specifies the build should be stopped if the executable can't start.

No

true

failonerror

Specifies the build should be stopped if the task encounters errors.

No

false

input

Specifies the file where the task should take input to run the executable with.

No

 

inputstring

Specifies a string holding the input stream for the executable to run.

No

 

logError

Specifies you want to send error output to Ant's log.

No

 

newenvironment

Specifies old environment variables should not be passed as new environment variables to a forked JVM.

No

false

os

Specifies the operating systems in which the executable can be run.

No

 

output

Specifies the name of a file in which to store the output.

No

 

outputproperty ...

Get Ant: The Definitive Guide, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.