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 5.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138
  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.</td>
  37. <td align="center" valign="top">No</td>
  38. </tr>
  39. <tr>
  40. <td valign="top">output</td>
  41. <td valign="top">the file to which the output of the command should be
  42. redirected.</td>
  43. <td align="center" valign="top">No</td>
  44. </tr>
  45. <tr>
  46. <td valign="top">timeout</td>
  47. <td valign="top">Stop the command if it doesn't finish within the
  48. specified time (given in milliseconds).</td>
  49. <td align="center" valign="top">No</td>
  50. </tr>
  51. <tr>
  52. <td valign="top">failonerror</td>
  53. <td valign="top">Stop the buildprocess if the command exits with a
  54. returncode other than 0.</td>
  55. <td align="center" valign="top">No</td>
  56. </tr>
  57. <tr>
  58. <td valign="top">newenvironment</td>
  59. <td valign="top">Do not propagate old environment when new environment
  60. variables are specified.</td>
  61. <td align="center" valign="top">No, default is <i>false</i></td>
  62. </tr>
  63. <tr>
  64. <td valign="top">parallel</td>
  65. <td valign="top">Run the command only once, appending all files as
  66. arguments. If false, command will be executed once for every file.
  67. Defaults to false. </td>
  68. <td align="center" valign="top">No</td>
  69. </tr>
  70. <tr>
  71. <td valign="top">type</td>
  72. <td valign="top">One of <i>file</i>, <i>dir</i> or
  73. <i>both</i>. If set to <i>file</i>, only the names of plain
  74. files will be sent to the command. If set to <i>dir</i>, only
  75. the names of directories are considered.</td>
  76. <td align="center" valign="top">No, default is <i>file</i></td>
  77. </tr>
  78. </table>
  79. <h3>Parameters specified as nested elements</h3>
  80. <h4>fileset</h4>
  81. <p>You can use any number of nested <code>&lt;fileset&gt;</code>
  82. elements to define the files for this task and refer to
  83. <code>&lt;fileset&gt;</code>s defined elsewhere.</p>
  84. <h4>arg</h4>
  85. <p>Command line arguments should be specified as nested
  86. <code>&lt;arg&gt;</code> elements. See <a
  87. href="../using.html#arg">Command line arguments</a>.</p>
  88. <h4>srcfile</h4>
  89. <p>By default the file names of the source files will be added to the
  90. end of the command line. If you need to place it somewhere different,
  91. use a nested <code>&lt;srcfile&gt;</code> element between your
  92. <code>&lt;arg&gt;</code> elements to mark the insertion point.</p>
  93. <h4>env</h4>
  94. <p>It is possible to specify environment variables to pass to the
  95. system command via nested <code>&lt;env&gt;</code> elements. See the
  96. description in the section about <a href="exec.html#env">exec</a></p>
  97. <p>Please note that the environment of the current Ant process is
  98. <b>not</b> passed to the system command if you specify variables using
  99. <code>&lt;env&gt;</code>.</p>
  100. <h3>Examples</h3>
  101. <blockquote><pre>
  102. &lt;execon executable=&quot;ls&quot; &gt;
  103. &lt;arg value=&quot;-l&quot;/&gt;
  104. &lt;fileset dir=&quot;/tmp&quot;&gt;
  105. &lt;patternset&gt;
  106. &lt;exclude name=&quot;**/*.txt&quot;/&gt;
  107. &lt;/patternset&gt;
  108. &lt;/fileset&gt;
  109. &lt;fileset refid=&quot;other.files&quot;/&gt;
  110. &lt;/execon&gt;
  111. </pre></blockquote>
  112. <p>invokes <code>ls -l</code>, adding the absolute filenames of all
  113. files below <code>/tmp</code> not ending in <code>.txt</code> and all
  114. files of the FileSet with <code>id</code> <code>other.files</code> to
  115. the command line.</p>
  116. <blockquote><pre>
  117. &lt;execon executable=&quot;somecommand&quot; parallel=&quot;false&quot; &gt;
  118. &lt;arg value=&quot;arg1&quot;/&gt;
  119. &lt;srfile/&gt;
  120. &lt;arg value=&quot;arg2&quot;/&gt;
  121. &lt;fileset dir=&quot;/tmp&quot;/&gt;
  122. &lt;/execon&gt;
  123. </pre></blockquote>
  124. <p>invokes <code>somecommand arg1 SOURCEFILENAME arg2</code> for each
  125. file in <code>/tmp</code> replacing SOURCEFILENAME with the absolute
  126. filename of each file in turn. If <code>parallel</code> had been set
  127. to true, SOURCEFILENAME would be replaced with the absolute filenames
  128. of all files separated by spaces.</p>
  129. <hr>
  130. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  131. Reserved.</p>
  132. </body>
  133. </html>