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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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 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="../CoreTypes/fileset.html">FileSet</a>s,
  30. <a href="../CoreTypes/dirset.html">DirSet</a>s or <a
  31. href="../CoreTypes/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="../CoreTypes/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. <h3>Parameters</h3>
  48. <table border="1" cellpadding="2" cellspacing="0">
  49. <tr>
  50. <td valign="top"><b>Attribute</b></td>
  51. <td valign="top"><b>Description</b></td>
  52. <td align="center" valign="top"><b>Required</b></td>
  53. </tr>
  54. <tr>
  55. <td valign="top">file</td>
  56. <td valign="top">the file or directory of which the owner must be
  57. changed.</td>
  58. <td valign="top" valign="middle">Yes or nested
  59. <code>&lt;fileset/list&gt;</code> elements.</td>
  60. </tr>
  61. <tr>
  62. <td valign="top">owner</td>
  63. <td valign="top">the new owner.</td>
  64. <td valign="top" align="center">Yes</td>
  65. </tr>
  66. <tr>
  67. <td valign="top">parallel</td>
  68. <td valign="top">process all specified files using a single
  69. <code>chown</code> command. Defaults to true.</td>
  70. <td valign="top" align="center">No</td>
  71. </tr>
  72. <tr>
  73. <td valign="top">type</td>
  74. <td valign="top">One of <i>file</i>, <i>dir</i> or
  75. <i>both</i>. If set to <i>file</i>, only the owner of
  76. plain files are going to be changed. If set to <i>dir</i>, only
  77. the directories are considered.<br>
  78. <strong>Note:</strong> The type attribute does not apply to
  79. nested <i>dirset</i>s - <i>dirset</i>s always implicitly
  80. assume type to be <i>dir</i>.</td>
  81. <td align="center" valign="top">No, default is <i>file</i></td>
  82. </tr>
  83. <tr>
  84. <td valign="top">maxparallel</td>
  85. <td valign="top">Limit the amount of parallelism by passing at
  86. most this many sourcefiles at once. Set it to &lt;= 0 for
  87. unlimited. Defaults to unlimited.</td>
  88. <td align="center" valign="top">No</td>
  89. </tr>
  90. <tr>
  91. <td valign="top">verbose</td>
  92. <td valign="top">Whether to print a summary after execution or not.
  93. Defaults to <code>false</code>.</td>
  94. <td align="center" valign="top">No</td>
  95. </tr>
  96. </table>
  97. <h3>Examples</h3>
  98. <blockquote><pre>
  99. &lt;chown file="${dist}/start.sh" owner="coderjoe"/&gt;
  100. </pre>
  101. </blockquote>
  102. <p>makes the "start.sh" file belong to coderjoe on a
  103. UNIX system.</p>
  104. <blockquote>
  105. <pre>
  106. &lt;chown owner="coderjoe"&gt;
  107. &lt;fileset dir="${dist}/bin" includes="**/*.sh"/&gt;
  108. &lt;/chown&gt;
  109. </pre>
  110. </blockquote>
  111. <p>makes all ".sh" files below <code>${dist}/bin</code>
  112. belong to coderjoe on a UNIX system.</p>
  113. <blockquote>
  114. <pre>
  115. &lt;chown owner="coderjoe"&gt;
  116. &lt;fileset dir="shared/sources1"&gt;
  117. &lt;exclude name="**/trial/**"/&gt;
  118. &lt;/fileset&gt;
  119. &lt;fileset refid="other.shared.sources"/&gt;
  120. &lt;/chown&gt;
  121. </pre>
  122. </blockquote>
  123. <p>makes all files below <code>shared/sources1</code> (except those
  124. below any directory named trial) belong to coderjoe on a UNIX
  125. system. In addition all files belonging to a FileSet
  126. with <code>id</code> <code>other.shared.sources</code> get the same
  127. owner.</p>
  128. <blockquote>
  129. <pre>
  130. &lt;chown owner="webadmin" type="file"&gt;
  131. &lt;fileset dir="/web"&gt;
  132. &lt;include name="**/*.cgi"/&gt;
  133. &lt;include name="**/*.old"/&gt;
  134. &lt;/fileset&gt;
  135. &lt;dirset dir="/web"&gt;
  136. &lt;include name="**/private_*"/&gt;
  137. &lt;/dirset&gt;
  138. &lt;/chmod&gt;
  139. </pre>
  140. </blockquote>
  141. <p>makes cgi scripts, files with a <code>.old</code> extension or
  142. directories beginning with <code>private_</code> belong to the user named
  143. webadmin. A directory ending in <code>.old</code> or a file beginning with
  144. <code>private_</code> would remain unaffected.</p>
  145. </body>
  146. </html>