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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. <html>
  2. <head>
  3. <meta http-equiv="Content-Language" content="en-us">
  4. <link rel="stylesheet" type="text/css" href="../stylesheets/style.css">
  5. <title>Chown Task</title>
  6. </head>
  7. <body>
  8. <h2><a name="Chown">Chown</a></h2>
  9. <p><em>Since Ant 1.6.</em></p>
  10. <h3>Description</h3>
  11. <p>Changes the owner of a file or all files inside specified
  12. directories. Right now it has effect only under Unix. The owner
  13. attribute is equivalent to the corresponding argument for the chown
  14. command.</p>
  15. <p><a href="../CoreTypes/fileset.html">FileSet</a>s,
  16. <a href="../CoreTypes/dirset.html">DirSet</a>s or <a
  17. href="../CoreTypes/filelist.html">FileList</a>s can be specified using
  18. nested <code>&lt;fileset&gt;</code>, <code>&lt;dirset&gt;</code> and
  19. <code>&lt;filelist&gt;</code> elements.</p>
  20. <p>Starting with Ant 1.7, this task supports arbitrary <a
  21. href="../CoreTypes/resources.html#collection">Resource Collection</a>s
  22. as nested elements.</p>
  23. <p>By default this task will use a single invocation of the underlying
  24. chown command. If you are working on a large number of files this may
  25. result in a command line that is too long for your operating system.
  26. If you encounter such problems, you should set the maxparallel
  27. attribute of this task to a non-zero value. The number to use highly
  28. depends on the length of your file names (the depth of your directory
  29. tree) and your operating system, so you'll have to experiment a
  30. little. POSIX recommends command line length limits of at least 4096
  31. characters, this may give you an approximation for the number you
  32. could use as initial value for these experiments.</p>
  33. <h3>Parameters</h3>
  34. <table border="1" cellpadding="2" cellspacing="0">
  35. <tr>
  36. <td valign="top"><b>Attribute</b></td>
  37. <td valign="top"><b>Description</b></td>
  38. <td align="center" valign="top"><b>Required</b></td>
  39. </tr>
  40. <tr>
  41. <td valign="top">file</td>
  42. <td valign="top">the file or directory of which the owner must be
  43. changed.</td>
  44. <td valign="top" valign="middle">Yes or nested
  45. <code>&lt;fileset/list&gt;</code> elements.</td>
  46. </tr>
  47. <tr>
  48. <td valign="top">owner</td>
  49. <td valign="top">the new owner.</td>
  50. <td valign="top" align="center">Yes</td>
  51. </tr>
  52. <tr>
  53. <td valign="top">parallel</td>
  54. <td valign="top">process all specified files using a single
  55. <code>chown</code> command. Defaults to true.</td>
  56. <td valign="top" align="center">No</td>
  57. </tr>
  58. <tr>
  59. <td valign="top">type</td>
  60. <td valign="top">One of <i>file</i>, <i>dir</i> or
  61. <i>both</i>. If set to <i>file</i>, only the owner of
  62. plain files are going to be changed. If set to <i>dir</i>, only
  63. the directories are considered.<br>
  64. <strong>Note:</strong> The type attribute does not apply to
  65. nested <i>dirset</i>s - <i>dirset</i>s always implicitly
  66. assume type to be <i>dir</i>.</td>
  67. <td align="center" valign="top">No, default is <i>file</i></td>
  68. </tr>
  69. <tr>
  70. <td valign="top">maxparallel</td>
  71. <td valign="top">Limit the amount of parallelism by passing at
  72. most this many sourcefiles at once. Set it to &lt;= 0 for
  73. unlimited. Defaults to unlimited.</td>
  74. <td align="center" valign="top">No</td>
  75. </tr>
  76. <tr>
  77. <td valign="top">verbose</td>
  78. <td valign="top">Whether to print a summary after execution or not.
  79. Defaults to <code>false</code>.</td>
  80. <td align="center" valign="top">No</td>
  81. </tr>
  82. </table>
  83. <h3>Examples</h3>
  84. <blockquote><pre>
  85. &lt;chown file="${dist}/start.sh" owner="coderjoe"/&gt;
  86. </pre>
  87. </blockquote>
  88. <p>makes the "start.sh" file belong to coderjoe on a
  89. UNIX system.</p>
  90. <blockquote>
  91. <pre>
  92. &lt;chown owner="coderjoe"&gt;
  93. &lt;fileset dir="${dist}/bin" includes="**/*.sh"/&gt;
  94. &lt;/chown&gt;
  95. </pre>
  96. </blockquote>
  97. <p>makes all ".sh" files below <code>${dist}/bin</code>
  98. belong to coderjoe on a UNIX system.</p>
  99. <blockquote>
  100. <pre>
  101. &lt;chown owner="coderjoe"&gt;
  102. &lt;fileset dir="shared/sources1"&gt;
  103. &lt;exclude name="**/trial/**"/&gt;
  104. &lt;/fileset&gt;
  105. &lt;fileset refid="other.shared.sources"/&gt;
  106. &lt;/chown&gt;
  107. </pre>
  108. </blockquote>
  109. <p>makes all files below <code>shared/sources1</code> (except those
  110. below any directory named trial) belong to coderjoe on a UNIX
  111. system. In addition all files belonging to a FileSet
  112. with <code>id</code> <code>other.shared.sources</code> get the same
  113. owner.</p>
  114. <blockquote>
  115. <pre>
  116. &lt;chown owner="webadmin" type="file"&gt;
  117. &lt;fileset dir="/web"&gt;
  118. &lt;include name="**/*.cgi"/&gt;
  119. &lt;include name="**/*.old"/&gt;
  120. &lt;/fileset&gt;
  121. &lt;dirset dir="/web"&gt;
  122. &lt;include name="**/private_*"/&gt;
  123. &lt;/dirset&gt;
  124. &lt;/chmod&gt;
  125. </pre>
  126. </blockquote>
  127. <p>makes cgi scripts, files with a <code>.old</code> extension or
  128. directories beginning with <code>private_</code> belong to the user named
  129. webadmin. A directory ending in <code>.old</code> or a file beginning with
  130. <code>private_</code> would remain unaffected.</p>
  131. <hr>
  132. <p align="center">Copyright &copy; 2002-2003,2005 Apache Software
  133. Foundation. All rights Reserved.</p>
  134. </body>
  135. </html>