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.

chown.html 6.3 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <!--
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. -->
  15. <html>
  16. <head>
  17. <meta http-equiv="Content-Language" content="en-us">
  18. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  19. <title>Chown Task</title>
  20. </head>
  21. <body>
  22. <h2><a name="Chown">Chown</a></h2>
  23. <p><em>Since Apache Ant 1.6.</em></p>
  24. <h3>Description</h3>
  25. <p>Changes the owner of a file or all files inside specified
  26. directories. Right now it has effect only under Unix. The owner
  27. attribute is equivalent to the corresponding argument for the chown
  28. command.</p>
  29. <p><a href="../Types/fileset.html">FileSet</a>s,
  30. <a href="../Types/dirset.html">DirSet</a>s or <a
  31. href="../Types/filelist.html">FileList</a>s can be specified using
  32. nested <code>&lt;fileset&gt;</code>, <code>&lt;dirset&gt;</code> and
  33. <code>&lt;filelist&gt;</code> elements.</p>
  34. <p>Starting with Ant 1.7, this task supports arbitrary <a
  35. href="../Types/resources.html#collection">Resource Collection</a>s
  36. as nested elements.</p>
  37. <p>By default this task will use a single invocation of the underlying
  38. chown command. If you are working on a large number of files this may
  39. result in a command line that is too long for your operating system.
  40. If you encounter such problems, you should set the maxparallel
  41. attribute of this task to a non-zero value. The number to use highly
  42. depends on the length of your file names (the depth of your directory
  43. tree) and your operating system, so you'll have to experiment a
  44. little. POSIX recommends command line length limits of at least 4096
  45. characters, this may give you an approximation for the number you
  46. could use as initial value for these experiments.</p>
  47. <p>By default this task won't do anything unless it detects it is
  48. running on a Unix system. If you know for sure that you have a
  49. "chown" executable on your PATH that is command line compatible with
  50. the Unix command, you can use the task's os attribute and set its
  51. value to your current os.</p>
  52. <h3>Parameters</h3>
  53. <table border="1" cellpadding="2" cellspacing="0">
  54. <tr>
  55. <td valign="top"><b>Attribute</b></td>
  56. <td valign="top"><b>Description</b></td>
  57. <td align="center" valign="top"><b>Required</b></td>
  58. </tr>
  59. <tr>
  60. <td valign="top">file</td>
  61. <td valign="top">the file or directory of which the owner must be
  62. changed.</td>
  63. <td valign="top" valign="middle">Yes or nested
  64. <code>&lt;fileset/list&gt;</code> elements.</td>
  65. </tr>
  66. <tr>
  67. <td valign="top">owner</td>
  68. <td valign="top">the new owner.</td>
  69. <td valign="top" align="center">Yes</td>
  70. </tr>
  71. <tr>
  72. <td valign="top">parallel</td>
  73. <td valign="top">process all specified files using a single
  74. <code>chown</code> command. Defaults to true.</td>
  75. <td valign="top" align="center">No</td>
  76. </tr>
  77. <tr>
  78. <td valign="top">type</td>
  79. <td valign="top">One of <i>file</i>, <i>dir</i> or
  80. <i>both</i>. If set to <i>file</i>, only the owner of
  81. plain files are going to be changed. If set to <i>dir</i>, only
  82. the directories are considered.<br>
  83. <strong>Note:</strong> The type attribute does not apply to
  84. nested <i>dirset</i>s - <i>dirset</i>s always implicitly
  85. assume type to be <i>dir</i>.</td>
  86. <td align="center" valign="top">No, default is <i>file</i></td>
  87. </tr>
  88. <tr>
  89. <td valign="top">maxparallel</td>
  90. <td valign="top">Limit the amount of parallelism by passing at
  91. most this many sourcefiles at once. Set it to &lt;= 0 for
  92. unlimited. Defaults to unlimited.</td>
  93. <td align="center" valign="top">No</td>
  94. </tr>
  95. <tr>
  96. <td valign="top">verbose</td>
  97. <td valign="top">Whether to print a summary after execution or not.
  98. Defaults to <code>false</code>.</td>
  99. <td align="center" valign="top">No</td>
  100. </tr>
  101. <tr>
  102. <td valign="top">os</td>
  103. <td valign="top">list of Operating Systems on which the command may be
  104. executed.</td>
  105. <td align="center" valign="top">No</td>
  106. </tr>
  107. <tr>
  108. <td valign="top">osfamily</td>
  109. <td valign="top">OS family as used in
  110. the <a href="../Tasks/conditions.html#os">&lt;os&gt;</a>
  111. condition.</td>
  112. <td align="center" valign="top">No - defaults to "unix"</td>
  113. </tr>
  114. </table>
  115. <h3>Examples</h3>
  116. <blockquote><pre>
  117. &lt;chown file="${dist}/start.sh" owner="coderjoe"/&gt;
  118. </pre>
  119. </blockquote>
  120. <p>makes the "start.sh" file belong to coderjoe on a
  121. UNIX system.</p>
  122. <blockquote>
  123. <pre>
  124. &lt;chown owner="coderjoe"&gt;
  125. &lt;fileset dir="${dist}/bin" includes="**/*.sh"/&gt;
  126. &lt;/chown&gt;
  127. </pre>
  128. </blockquote>
  129. <p>makes all ".sh" files below <code>${dist}/bin</code>
  130. belong to coderjoe on a UNIX system.</p>
  131. <blockquote>
  132. <pre>
  133. &lt;chown owner="coderjoe"&gt;
  134. &lt;fileset dir="shared/sources1"&gt;
  135. &lt;exclude name="**/trial/**"/&gt;
  136. &lt;/fileset&gt;
  137. &lt;fileset refid="other.shared.sources"/&gt;
  138. &lt;/chown&gt;
  139. </pre>
  140. </blockquote>
  141. <p>makes all files below <code>shared/sources1</code> (except those
  142. below any directory named trial) belong to coderjoe on a UNIX
  143. system. In addition all files belonging to a FileSet
  144. with <code>id</code> <code>other.shared.sources</code> get the same
  145. owner.</p>
  146. <blockquote>
  147. <pre>
  148. &lt;chown owner="webadmin" type="file"&gt;
  149. &lt;fileset dir="/web"&gt;
  150. &lt;include name="**/*.cgi"/&gt;
  151. &lt;include name="**/*.old"/&gt;
  152. &lt;/fileset&gt;
  153. &lt;dirset dir="/web"&gt;
  154. &lt;include name="**/private_*"/&gt;
  155. &lt;/dirset&gt;
  156. &lt;/chmod&gt;
  157. </pre>
  158. </blockquote>
  159. <p>makes cgi scripts, files with a <code>.old</code> extension or
  160. directories beginning with <code>private_</code> belong to the user named
  161. webadmin. A directory ending in <code>.old</code> or a file beginning with
  162. <code>private_</code> would remain unaffected.</p>
  163. </body>
  164. </html>