1 | <html>
|
---|
2 |
|
---|
3 | <head>
|
---|
4 | <meta http-equiv="Content-Language" content="en-us">
|
---|
5 | <title>Chmod Task</title>
|
---|
6 | <link rel="stylesheet" type="text/css" href="../stylesheets/antmanual.css">
|
---|
7 | </head>
|
---|
8 |
|
---|
9 | <body>
|
---|
10 |
|
---|
11 | <h2><a name="chmod">Chmod</a></h2>
|
---|
12 | <h3>Description</h3>
|
---|
13 | <p>Changes the permissions of a file or all files inside specified
|
---|
14 | directories. Right now it has effect only under Unix or NonStop Kernel (Tandem).
|
---|
15 | The permissions are also UNIX style, like the argument for the chmod command.</p>
|
---|
16 | <p>See the section on <a href="../dirtasks.html#directorybasedtasks">directory based
|
---|
17 | tasks</a>, on how the inclusion/exclusion of files works, and how to
|
---|
18 | write patterns.</p>
|
---|
19 |
|
---|
20 | <p>This task holds an implicit <a
|
---|
21 | href="../CoreTypes/fileset.html">FileSet</a> and supports all of
|
---|
22 | FileSet's attributes and nested elements directly. More sets can be
|
---|
23 | specified using nested <code><fileset></code> or
|
---|
24 | <code><dirset></code> (<em>since Ant 1.6</em>) elements. </p>
|
---|
25 |
|
---|
26 | <p>Starting with Ant 1.6, this task also supports nested <a
|
---|
27 | href="../CoreTypes/filelist.html">filelist</a>s.</p>
|
---|
28 |
|
---|
29 | <p>By default this task will use a single invocation of the underlying
|
---|
30 | chmod command. If you are working on a large number of files this may
|
---|
31 | result in a command line that is too long for your operating system.
|
---|
32 | If you encounter such problems, you should set the maxparallel
|
---|
33 | attribute of this task to a non-zero value. The number to use highly
|
---|
34 | depends on the length of your file names (the depth of your directory
|
---|
35 | tree) and your operating system, so you'll have to experiment a
|
---|
36 | little. POSIX recommends command line length limits of at least 4096
|
---|
37 | characters, this may give you an approximation for the number you
|
---|
38 | could use as initial value for these experiments.</p>
|
---|
39 |
|
---|
40 | <h3>Parameters</h3>
|
---|
41 | <table border="1" cellpadding="2" cellspacing="0">
|
---|
42 | <tr>
|
---|
43 | <td valign="top"><b>Attribute</b></td>
|
---|
44 | <td valign="top"><b>Description</b></td>
|
---|
45 | <td align="center" valign="top"><b>Required</b></td>
|
---|
46 | </tr>
|
---|
47 | <tr>
|
---|
48 | <td valign="top">file</td>
|
---|
49 | <td valign="top">the file or single directory of which the permissions
|
---|
50 | must be changed.</td>
|
---|
51 | <td valign="top" valign="middle" rowspan="2">exactly one of the two or nested <code><fileset/list></code> elements.</td>
|
---|
52 | </tr>
|
---|
53 | <tr>
|
---|
54 | <td valign="top">dir</td>
|
---|
55 | <td valign="top">the directory which holds the files whose permissions
|
---|
56 | must be changed.</td>
|
---|
57 | </tr>
|
---|
58 | <tr>
|
---|
59 | <td valign="top">perm</td>
|
---|
60 | <td valign="top">the new permissions.</td>
|
---|
61 | <td valign="top" align="center">Yes</td>
|
---|
62 | </tr>
|
---|
63 | <tr>
|
---|
64 | <td valign="top">includes</td>
|
---|
65 | <td valign="top">comma- or space-separated list of patterns of files that must be
|
---|
66 | included.</td>
|
---|
67 | <td valign="top" align="center">No</td>
|
---|
68 | </tr>
|
---|
69 | <tr>
|
---|
70 | <td valign="top">excludes</td>
|
---|
71 | <td valign="top">comma- or space-separated list of patterns of files that must be
|
---|
72 | excluded. No files (except default excludes) are excluded when omitted.</td>
|
---|
73 | <td valign="top" align="center">No</td>
|
---|
74 | </tr>
|
---|
75 | <tr>
|
---|
76 | <td valign="top">defaultexcludes</td>
|
---|
77 | <td valign="top">indicates whether default excludes should be used or not
|
---|
78 | ("yes"/"no"). Default excludes are used when omitted.</td>
|
---|
79 | <td valign="top" align="center">No</td>
|
---|
80 | </tr>
|
---|
81 | <tr>
|
---|
82 | <td valign="top">parallel</td>
|
---|
83 | <td valign="top">process all specified files using a single
|
---|
84 | <code>chmod</code> command. Defaults to true.</td>
|
---|
85 | <td valign="top" align="center">No</td>
|
---|
86 | </tr>
|
---|
87 | <tr>
|
---|
88 | <td valign="top">type</td>
|
---|
89 | <td valign="top">One of <i>file</i>, <i>dir</i> or
|
---|
90 | <i>both</i>. If set to <i>file</i>, only the permissions of
|
---|
91 | plain files are going to be changed. If set to <i>dir</i>, only
|
---|
92 | the directories are considered.<br>
|
---|
93 | <strong>Note:</strong> The type attribute does not apply to
|
---|
94 | nested <i>dirset</i>s - <i>dirset</i>s always implicitly
|
---|
95 | assume type to be <i>dir</i>.</td>
|
---|
96 | <td align="center" valign="top">No, default is <i>file</i></td>
|
---|
97 | </tr>
|
---|
98 | <tr>
|
---|
99 | <td valign="top">maxparallel</td>
|
---|
100 | <td valign="top">Limit the amount of parallelism by passing at
|
---|
101 | most this many sourcefiles at once. Set it to <= 0 for
|
---|
102 | unlimited. Defaults to unlimited. <em>Since Ant 1.6.</em></td>
|
---|
103 | <td align="center" valign="top">No</td>
|
---|
104 | </tr>
|
---|
105 | <tr>
|
---|
106 | <td valign="top">verbose</td>
|
---|
107 | <td valign="top">Whether to print a summary after execution or not.
|
---|
108 | Defaults to <code>false</code>. <em>Since Ant 1.6.</em></td>
|
---|
109 | <td align="center" valign="top">No</td>
|
---|
110 | </tr>
|
---|
111 | </table>
|
---|
112 | <h3>Examples</h3>
|
---|
113 | <blockquote><pre>
|
---|
114 | <chmod file="${dist}/start.sh" perm="ugo+rx"/>
|
---|
115 | </pre></blockquote>
|
---|
116 | <p>makes the "start.sh" file readable and executable for anyone on a
|
---|
117 | UNIX system.</p>
|
---|
118 | <blockquote><pre>
|
---|
119 | <chmod file="${dist}/start.sh" perm="700"/>
|
---|
120 | </pre></blockquote>
|
---|
121 | <p>makes the "start.sh" file readable, writable and executable only for the owner on a
|
---|
122 | UNIX system.</p>
|
---|
123 | <blockquote>
|
---|
124 | <pre>
|
---|
125 | <chmod dir="${dist}/bin" perm="ugo+rx"
|
---|
126 | includes="**/*.sh"/>
|
---|
127 | </pre>
|
---|
128 | </blockquote>
|
---|
129 | <p>makes all ".sh" files below <code>${dist}/bin</code>
|
---|
130 | readable and executable for anyone on a UNIX system.</p>
|
---|
131 | <blockquote>
|
---|
132 | <pre>
|
---|
133 | <chmod perm="g+w">
|
---|
134 | <fileset dir="shared/sources1">
|
---|
135 | <exclude name="**/trial/**"/>
|
---|
136 | </fileset>
|
---|
137 | <fileset refid="other.shared.sources"/>
|
---|
138 | </chmod>
|
---|
139 | </pre>
|
---|
140 | </blockquote>
|
---|
141 | <p>makes all files below <code>shared/sources1</code> (except those
|
---|
142 | below any directory named trial) writable for members of the same
|
---|
143 | group on a UNIX system. In addition all files belonging to a FileSet
|
---|
144 | with <code>id</code> <code>other.shared.sources</code> get the same
|
---|
145 | permissions.</p>
|
---|
146 |
|
---|
147 | <blockquote>
|
---|
148 | <pre>
|
---|
149 | <chmod perm="go-rwx" type="file">
|
---|
150 | <fileset dir="/web">
|
---|
151 | <include name="**/*.cgi"/>
|
---|
152 | <include name="**/*.old"/>
|
---|
153 | </fileset>
|
---|
154 | <dirset dir="/web">
|
---|
155 | <include name="**/private_*"/>
|
---|
156 | </dirset>
|
---|
157 | </chmod>
|
---|
158 | </pre>
|
---|
159 | </blockquote>
|
---|
160 |
|
---|
161 | <p>keeps non-owners from touching cgi scripts, files with a <code>.old</code>
|
---|
162 | extension or directories beginning with <code>private_</code>. A directory
|
---|
163 | ending in <code>.old</code> or a file beginning with private_ would remain
|
---|
164 | unaffected.</p>
|
---|
165 |
|
---|
166 | <hr>
|
---|
167 | <p align="center">Copyright © 2000-2005 The Apache Software Foundation.
|
---|
168 | All rights Reserved.</p>
|
---|
169 |
|
---|
170 | </body>
|
---|
171 | </html>
|
---|
172 |
|
---|