# Ant User Manual

## ExecOn

### Description

Executes a system command. When the os attribute is specified, then the command is only executed when Ant is run on one of the specified operating systems.

The files and/or directories of a number of FileSets are passed as arguments to the system command. At least one nested `<fileset>` is required.

### Parameters

Attribute | Description | Required
executable | the command to execute without any command line arguments. | Yes
dir | the directory in which the command should be executed. | No
os | list of Operating Systems on which the command may be executed. | No
output | the file to which the output of the command should be redirected. | No
timeout | Stop the command if it doesn't finish within the specified time (given in milliseconds). | No
failonerror | Stop the buildprocess if the command exits with a returncode other than 0. | No
newenvironment | Do not propagate old environment when new environment variables are specified. | No, default is false
parallel | Run the command only once, appending all files as arguments. If false, command will be executed once for every file. Defaults to false. | No
type | One of file, dir or both. If set to file, only the names of plain files will be sent to the command. If set to dir, only the names of directories are considered. | No, default is file

### Parameters specified as nested elements

#### fileset

You can use any number of nested `<fileset>` elements to define the files for this task and refer to `<fileset>`s defined elsewhere.

#### arg

Command line arguments should be specified as nested `<arg>` elements. See Command line arguments.

#### srcfile

By default the file names of the source files will be added to the end of the command line. If you need to place it somewhere different, use a nested `<srcfile>` element between your `<arg>` elements to mark the insertion point.

#### env

It is possible to specify environment variables to pass to the system command via nested `<env>` elements. See the description in the section about exec

Please note that the environment of the current Ant process is not passed to the system command if you specify variables using `<env>`.

### Examples

>     <execon executable="ls" >
>       <arg value="-l"/>
>       <fileset dir="/tmp">
>         <patternset>
>           <exclude name="**/*.txt"/>
>         </patternset>
>       </fileset>
>       <fileset refid="other.files"/>
>     </execon>

invokes `ls -l`, adding the absolute filenames of all files below `/tmp` not ending in `.txt` and all files of the FileSet with `id` `other.files` to the command line.

>     <execon executable="somecommand" parallel="false" >
>       <arg value="arg1"/>
>       <srfile/>
>       <arg value="arg2"/>
>       <fileset dir="/tmp"/>
>     </execon>

invokes `somecommand arg1 SOURCEFILENAME arg2` for each file in `/tmp` replacing SOURCEFILENAME with the absolute filename of each file in turn. If `parallel` had been set to true, SOURCEFILENAME would be replaced with the absolute filenames of all files separated by spaces.

Copyright © 2000,2001 Apache Software Foundation. All rights Reserved.