mirror of
https://github.com/apache/ant.git
synced 2025-05-15 20:45:11 +00:00
PR: 5020 Reported By: jesse.glick@netbeans.com (Jesse Glick) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@271131 13f79535-47bb-0310-9956-ffa450edef68
172 lines
6.3 KiB
HTML
172 lines
6.3 KiB
HTML
<html>
|
|
|
|
<head>
|
|
<meta http-equiv="Content-Language" content="en-us">
|
|
<title>Exec Task</title>
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<h2><a name="exec">Exec</a></h2>
|
|
<h3>Description</h3>
|
|
<p>Executes a system command. When the <i>os</i> attribute is specified, then
|
|
the command is only executed when Ant is run on one of the specified operating
|
|
systems.</p>
|
|
<h3>Parameters</h3>
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td valign="top"><b>Attribute</b></td>
|
|
<td valign="top"><b>Description</b></td>
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">command</td>
|
|
<td valign="top">the command to execute with all command line
|
|
arguments. <b>deprecated, use executable and nested
|
|
<code><arg></code> elements instead</b>.</td>
|
|
<td align="center" rowspan="2">Exactly one of the two.</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">executable</td>
|
|
<td valign="top">the command to execute without any command line
|
|
arguments.</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">dir</td>
|
|
<td valign="top">the directory in which the command should be executed.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">os</td>
|
|
<td valign="top">list of Operating Systems on which the command may be
|
|
executed. If the current OS's name is contained in this list, the command will
|
|
be executed. The OS's name is determined by the Java Virtual machine and is set
|
|
in the "os.name" system property.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">output</td>
|
|
<td valign="top">the file to which the output of the command should be
|
|
redirected.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">outputproperty</td>
|
|
<td valign="top">the name of a property in which the output of the
|
|
command should be stored.</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">resultproperty</td>
|
|
<td valign="top">the name of a property in which the return code of the
|
|
command should be stored. Only of interest if failonerror=false</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">timeout</td>
|
|
<td valign="top">Stop the command if it doesn't finish within the
|
|
specified time (given in milliseconds).</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">failonerror</td>
|
|
<td valign="top">Stop the buildprocess if the command exits with a
|
|
returncode other than 0. Defaults to false</td>
|
|
<td align="center" valign="top">No</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">newenvironment</td>
|
|
<td valign="top">Do not propagate old environment when new environment
|
|
variables are specified.</td>
|
|
<td align="center" valign="top">No, default is <i>false</i></td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">vmlauncher</td>
|
|
<td valign="top">Run command using the Java VM's execution facilities
|
|
where available. If set to false the underlying OS's shell,
|
|
either directly or through the antRun scripts, will be used.
|
|
Under some operating systems, this gives access to facilities
|
|
not normally available through the VM including, under Windows,
|
|
being able to execute scripts, rather than their associated
|
|
interpreter.</td>
|
|
<td align="center" valign="top">No, default is <i>true</i></td>
|
|
</tr>
|
|
</table>
|
|
<h3>Examples</h3>
|
|
<blockquote>
|
|
<pre>
|
|
<exec dir="${src}" executable="cmd.exe" os="Windows 2000" output="dir.txt">
|
|
<arg line="/c dir"/>
|
|
</exec></pre>
|
|
</blockquote>
|
|
<h3>Parameters specified as nested elements</h3>
|
|
<h4>arg</h4>
|
|
<p>Command line arguments should be specified as nested
|
|
<code><arg></code> elements. See <a
|
|
href="../using.html#arg">Command line arguments</a>.</p>
|
|
<h4><a name="env">env</a></h4>
|
|
<p>It is possible to specify environment variables to pass to the
|
|
system command via nested <code><env></code> elements.</p>
|
|
<table border="1" cellpadding="2" cellspacing="0">
|
|
<tr>
|
|
<td valign="top"><b>Attribute</b></td>
|
|
<td valign="top"><b>Description</b></td>
|
|
<td align="center" valign="top"><b>Required</b></td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">key</td>
|
|
<td valign="top">The name of the environment variable.</td>
|
|
<td align="center" valign="top">Yes</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">value</td>
|
|
<td valign="top">The literal value for the environment variable.</td>
|
|
<td align="center" rowspan="3">Exactly one of these.</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">path</td>
|
|
<td valign="top">The value for a PATH like environment
|
|
variable. You can use ; or : as path separators and Ant will
|
|
convert it to the platform's local conventions.</td>
|
|
</tr>
|
|
<tr>
|
|
<td valign="top">file</td>
|
|
<td valign="top">The value for the environment variable. Will be
|
|
replaced by the absolute filename of the file by Ant.</td>
|
|
</tr>
|
|
</table>
|
|
<h5>Examples</h5>
|
|
<blockquote><pre>
|
|
<exec executable="emacs" >
|
|
<env key="DISPLAY" value=":1.0"/>
|
|
</exec>
|
|
</pre></blockquote>
|
|
<p>starts <code>emacs</code> on display 1 of the X Window System.</p>
|
|
<blockquote><pre>
|
|
<exec ... >
|
|
<env key="PATH" path="${java.library.path}:${basedir}/bin"/>
|
|
</exec>
|
|
</pre></blockquote>
|
|
<p>adds <code>${basedir}/bin</code> to the <code>PATH</code> of the
|
|
system command.</p>
|
|
<p><b>Note:</b> Although it may work for you to specify arguments using
|
|
a simple arg-element and separate them by spaces it may fail if you switch to
|
|
a newer version of the JDK. JDK < 1.2 will pass these as separate arguments
|
|
to the program you are calling, JDK >= 1.2 will pass them as a single
|
|
argument and cause most calls to fail.</p>
|
|
<p><b>Note2:</b> If you are using Ant on Windows and a new DOS-Window pops up
|
|
for every command which is executed this may be a problem of the JDK you are using.
|
|
This problem may occur with all JDK's < 1.2.</p>
|
|
<p>
|
|
<b>Timeouts: </b> If a timeout is specified, when it is reached the
|
|
sub process is killed and a message printed to the log. The return
|
|
value of the execution will be "-1", which will halt the build if
|
|
<tt>failonerror=true</tt>, but be ignored otherwise.
|
|
<hr>
|
|
<p align="center">Copyright © 2001-2002 Apache Software Foundation. All rights
|
|
Reserved.</p>
|
|
|
|
</body>
|
|
</html>
|
|
|