You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

execon.html 6.1 kB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <title>Ant User Manual</title>
  5. </head>
  6. <body>
  7. <h2><a name="execon">ExecOn</a></h2>
  8. <h3>Description</h3>
  9. <p>Executes a system command. When the <i>os</i> attribute is specified, then
  10. the command is only executed when Ant is run on one of the specified operating
  11. systems.</p>
  12. <p>The files and/or directories of a number of <a
  13. href="../CoreTypes/fileset.html">FileSet</a>s are passed as arguments to the system
  14. command. At least one nested <code>&lt;fileset&gt;</code> is required.</p>
  15. <h3>Parameters</h3>
  16. <table border="1" cellpadding="2" cellspacing="0">
  17. <tr>
  18. <td valign="top"><b>Attribute</b></td>
  19. <td valign="top"><b>Description</b></td>
  20. <td align="center" valign="top"><b>Required</b></td>
  21. </tr>
  22. <tr>
  23. <td valign="top">executable</td>
  24. <td valign="top">the command to execute without any command line
  25. arguments.</td>
  26. <td align="center" valign="top">Yes</td>
  27. </tr>
  28. <tr>
  29. <td valign="top">dir</td>
  30. <td valign="top">the directory in which the command should be executed.</td>
  31. <td align="center" valign="top">No</td>
  32. </tr>
  33. <tr>
  34. <td valign="top">os</td>
  35. <td valign="top">list of Operating Systems on which the command may be
  36. executed. If the current OS's name is contained in this list, the command will
  37. be executed. The OS's name is determined by the Java Virtual machine and is set
  38. in the &quot;os.name&quot; system property.</td>
  39. </tr>
  40. <tr>
  41. <td valign="top">output</td>
  42. <td valign="top">the file to which the output of the command should be
  43. redirected.</td>
  44. <td align="center" valign="top">No</td>
  45. </tr>
  46. <tr>
  47. <td valign="top">timeout</td>
  48. <td valign="top">Stop the command if it doesn't finish within the
  49. specified time (given in milliseconds).</td>
  50. <td align="center" valign="top">No</td>
  51. </tr>
  52. <tr>
  53. <td valign="top">failonerror</td>
  54. <td valign="top">Stop the buildprocess if the command exits with a
  55. returncode other than 0.</td>
  56. <td align="center" valign="top">No</td>
  57. </tr>
  58. <tr>
  59. <td valign="top">newenvironment</td>
  60. <td valign="top">Do not propagate old environment when new environment
  61. variables are specified.</td>
  62. <td align="center" valign="top">No, default is <i>false</i></td>
  63. </tr>
  64. <tr>
  65. <td valign="top">vmlauncher</td>
  66. <td valign="top">Run command using the Java VM's execution facilities
  67. where available. If set to false the underlying OS's shell,
  68. either directly or through the antRun scripts, will be used.
  69. Under some operating systems, this gives access to facilities
  70. not nomrally available through the VM including, under Windows,
  71. being able to execute scripts, rather than their associated
  72. interpreter.</td>
  73. <td align="center" valign="top">No, default is <i>true</i></td>
  74. </tr>
  75. <tr>
  76. <td valign="top">skipemptyfilesets</td>
  77. <td valign="top">Don't run the command, if no source files have
  78. been found.</td>
  79. <td align="center" valign="top">No, default is <i>false</i></td>
  80. </tr>
  81. <tr>
  82. <td valign="top">parallel</td>
  83. <td valign="top">Run the command only once, appending all files as
  84. arguments. If false, command will be executed once for every file.
  85. Defaults to false. </td>
  86. <td align="center" valign="top">No</td>
  87. </tr>
  88. <tr>
  89. <td valign="top">type</td>
  90. <td valign="top">One of <i>file</i>, <i>dir</i> or
  91. <i>both</i>. If set to <i>file</i>, only the names of plain
  92. files will be sent to the command. If set to <i>dir</i>, only
  93. the names of directories are considered.</td>
  94. <td align="center" valign="top">No, default is <i>file</i></td>
  95. </tr>
  96. </table>
  97. <h3>Parameters specified as nested elements</h3>
  98. <h4>fileset</h4>
  99. <p>You can use any number of nested <code>&lt;fileset&gt;</code>
  100. elements to define the files for this task and refer to
  101. <code>&lt;fileset&gt;</code>s defined elsewhere.</p>
  102. <h4>arg</h4>
  103. <p>Command line arguments should be specified as nested
  104. <code>&lt;arg&gt;</code> elements. See <a
  105. href="../using.html#arg">Command line arguments</a>.</p>
  106. <h4>srcfile</h4>
  107. <p>By default the file names of the source files will be added to the
  108. end of the command line. If you need to place it somewhere different,
  109. use a nested <code>&lt;srcfile&gt;</code> element between your
  110. <code>&lt;arg&gt;</code> elements to mark the insertion point.</p>
  111. <h4>env</h4>
  112. <p>It is possible to specify environment variables to pass to the
  113. system command via nested <code>&lt;env&gt;</code> elements. See the
  114. description in the section about <a href="exec.html#env">exec</a></p>
  115. <p>Please note that the environment of the current Ant process is
  116. <b>not</b> passed to the system command if you specify variables using
  117. <code>&lt;env&gt;</code>.</p>
  118. <h3>Examples</h3>
  119. <blockquote><pre>
  120. &lt;execon executable=&quot;ls&quot; &gt;
  121. &lt;arg value=&quot;-l&quot;/&gt;
  122. &lt;fileset dir=&quot;/tmp&quot;&gt;
  123. &lt;patternset&gt;
  124. &lt;exclude name=&quot;**/*.txt&quot;/&gt;
  125. &lt;/patternset&gt;
  126. &lt;/fileset&gt;
  127. &lt;fileset refid=&quot;other.files&quot;/&gt;
  128. &lt;/execon&gt;
  129. </pre></blockquote>
  130. <p>invokes <code>ls -l</code>, adding the absolute filenames of all
  131. files below <code>/tmp</code> not ending in <code>.txt</code> and all
  132. files of the FileSet with <code>id</code> <code>other.files</code> to
  133. the command line.</p>
  134. <blockquote><pre>
  135. &lt;execon executable=&quot;somecommand&quot; parallel=&quot;false&quot; &gt;
  136. &lt;arg value=&quot;arg1&quot;/&gt;
  137. &lt;srfile/&gt;
  138. &lt;arg value=&quot;arg2&quot;/&gt;
  139. &lt;fileset dir=&quot;/tmp&quot;/&gt;
  140. &lt;/execon&gt;
  141. </pre></blockquote>
  142. <p>invokes <code>somecommand arg1 SOURCEFILENAME arg2</code> for each
  143. file in <code>/tmp</code> replacing SOURCEFILENAME with the absolute
  144. filename of each file in turn. If <code>parallel</code> had been set
  145. to true, SOURCEFILENAME would be replaced with the absolute filenames
  146. of all files separated by spaces.</p>
  147. <hr>
  148. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  149. Reserved.</p>
  150. </body>
  151. </html>