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.

exec.html 5.0 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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="exec">Exec</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. <h3>Parameters</h3>
  13. <table border="1" cellpadding="2" cellspacing="0">
  14. <tr>
  15. <td valign="top"><b>Attribute</b></td>
  16. <td valign="top"><b>Description</b></td>
  17. <td align="center" valign="top"><b>Required</b></td>
  18. </tr>
  19. <tr>
  20. <td valign="top">command</td>
  21. <td valign="top">the command to execute with all command line
  22. arguments. <b>deprecated, use executable and nested
  23. <code>&lt;arg&gt;</code> elements instead</b>.</td>
  24. <td align="center" rowspan="2">Exactly one of the two.</td>
  25. </tr>
  26. <tr>
  27. <td valign="top">executable</td>
  28. <td valign="top">the command to execute without any command line
  29. arguments.</td>
  30. </tr>
  31. <tr>
  32. <td valign="top">dir</td>
  33. <td valign="top">the directory in which the command should be executed.</td>
  34. <td align="center" valign="top">No</td>
  35. </tr>
  36. <tr>
  37. <td valign="top">os</td>
  38. <td valign="top">list of Operating Systems on which the command may be
  39. executed.</td>
  40. <td align="center" valign="top">No</td>
  41. </tr>
  42. <tr>
  43. <td valign="top">output</td>
  44. <td valign="top">the file to which the output of the command should be
  45. redirected.</td>
  46. <td align="center" valign="top">No</td>
  47. </tr>
  48. <tr>
  49. <td valign="top">timeout</td>
  50. <td valign="top">Stop the command if it doesn't finish within the
  51. specified time (given in milliseconds).</td>
  52. <td align="center" valign="top">No</td>
  53. </tr>
  54. <tr>
  55. <td valign="top">failonerror</td>
  56. <td valign="top">Stop the buildprocess if the command exits with a
  57. returncode other than 0.</td>
  58. <td align="center" valign="top">No</td>
  59. </tr>
  60. <tr>
  61. <td valign="top">newenvironment</td>
  62. <td valign="top">Do not propagate old environment when new environment
  63. variables are specified.</td>
  64. <td align="center" valign="top">No, default is <i>false</i></td>
  65. </tr>
  66. </table>
  67. <h3>Examples</h3>
  68. <blockquote>
  69. <pre>
  70. &lt;exec dir=&quot;${src}&quot; executable=&quot;cmd.exe&quot; os=&quot;Windows 2000&quot; output=&quot;dir.txt&quot;&gt;
  71. &lt;arg line=&quot;/c dir&quot;/&gt;
  72. &lt;/exec&gt;</pre>
  73. </blockquote>
  74. <h3>Parameters specified as nested elements</h3>
  75. <h4>arg</h4>
  76. <p>Command line arguments should be specified as nested
  77. <code>&lt;arg&gt;</code> elements. See <a
  78. href="../using.html#arg">Command line arguments</a>.</p>
  79. <h4><a name="env">env</a></h4>
  80. <p>It is possible to specify environment variables to pass to the
  81. system command via nested <code>&lt;env&gt;</code> elements.</p>
  82. <p>Please note that the environment of the current Ant process is
  83. <b>not</b> passed to the system command if you specify variables using
  84. <code>&lt;env&gt;</code>.</p>
  85. <table border="1" cellpadding="2" cellspacing="0">
  86. <tr>
  87. <td valign="top"><b>Attribute</b></td>
  88. <td valign="top"><b>Description</b></td>
  89. <td align="center" valign="top"><b>Required</b></td>
  90. </tr>
  91. <tr>
  92. <td valign="top">key</td>
  93. <td valign="top">The name of the environment variable.</td>
  94. <td align="center" valign="top">Yes</td>
  95. </tr>
  96. <tr>
  97. <td valign="top">value</td>
  98. <td valign="top">The literal value for the environment variable.</td>
  99. <td align="center" rowspan="3">Exactly one of these.</td>
  100. </tr>
  101. <tr>
  102. <td valign="top">path</td>
  103. <td valign="top">The value for a PATH like environment
  104. variable. You can use ; or : as path separators and Ant will
  105. convert it to the platform's local conventions.</td>
  106. </tr>
  107. <tr>
  108. <td valign="top">file</td>
  109. <td valign="top">The value for the environment variable. Will be
  110. replaced by the absolute filename of the file by Ant.</td>
  111. </tr>
  112. </table>
  113. <h5>Examples</h5>
  114. <blockquote><pre>
  115. &lt;exec executable=&quot;emacs&quot; &gt;
  116. &lt;env key=&quot;DISPLAY&quot; value=&quot;:1.0&quot;/&gt;
  117. &lt;/exec&gt;
  118. </pre></blockquote>
  119. <p>starts <code>emacs</code> on display 1 of the X Window System.</p>
  120. <blockquote><pre>
  121. &lt;exec ... &gt;
  122. &lt;env key=&quot;PATH&quot; path=&quot;${java.library.path}:${basedir}/bin&quot;/&gt;
  123. &lt;/exec&gt;
  124. </pre></blockquote>
  125. <p>adds <code>${basedir}/bin</code> to the <code>PATH</code> of the
  126. system command.</p>
  127. <p><b>Note:</b> Although it may work for you to specify arguments using
  128. a simple arg-element and separate them by spaces it may fail if you switch to
  129. a newer version of the JDK. JDK &lt; 1.2 will pass these as separate arguments
  130. to the program you are calling, JDK &gt;= 1.2 will pass them as a single
  131. argument and cause most calls to fail.</p>
  132. <p><b>Note2:</b> If you are using Ant on Windows and a new DOS-Window pops up
  133. for every command which is executed this may be a problem of the JDK you are using.
  134. This problem may occur with all JDK's &lt; 1.2.</p>
  135. <hr>
  136. <p align="center">Copyright &copy; 2000,2001 Apache Software Foundation. All rights
  137. Reserved.</p>
  138. </body>
  139. </html>