java left logo
java middle logo
java right logo
 

Home arrow Other API Tips
 
 
Main Menu
Home
Java Tutorials
Book Reviews
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Java Network
Java Forums
Java Blog




Most Visited Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews
Top Rated Tips
Java SE Tips
Java ME Tips
Java EE Tips
Other API Tips
Java Applications
Java Libraries
Java Games
Book Reviews


Statistics
Registered Users: 4085
Java SE Tips: 614
Java ME Tips: 202
Java EE Tips: 183
Other API Tips: 779
Java Applications: 298
Java Libraries: 209
Java Games: 16
Book Reviews:
 
 
 
How to use Chmod task E-mail
User Rating: / 2
PoorBest 

Chmod

Description

Changes the permissions of a file or all files inside specified directories. Right now it has effect only under Unix or NonStop Kernel (Tandem). The permissions are also UNIX style, like the argument for the chmod command.

See the section on directory based tasks, on how the inclusion/exclusion of files works, and how to write patterns.

This task holds an implicit FileSet and supports all of FileSet's attributes and nested elements directly. More sets can be specified using nested <fileset> or <dirset> (since Ant 1.6) elements.

Starting with Ant 1.6, this task also supports nested filelists.

By default this task will use a single invocation of the underlying chmod command. If you are working on a large number of files this may result in a command line that is too long for your operating system. If you encounter such problems, you should set the maxparallel attribute of this task to a non-zero value. The number to use highly depends on the length of your file names (the depth of your directory tree) and your operating system, so you'll have to experiment a little. POSIX recommends command line length limits of at least 4096 characters, this may give you an approximation for the number you could use as initial value for these experiments.

Parameters

Attribute Description Required
file the file or single directory of which the permissions must be changed. exactly one of the two or nested <fileset/list> elements.
dir the directory which holds the files whose permissions must be changed.
perm the new permissions. Yes
includes comma- or space-separated list of patterns of files that must be included. No
excludes comma- or space-separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted. No
defaultexcludes indicates whether default excludes should be used or not ("yes"/"no"). Default excludes are used when omitted. No
parallel process all specified files using a single chmod command. Defaults to true. No
type One of file, dir or both. If set to file, only the permissions of plain files are going to be changed. If set to dir, only the directories are considered.
Note: The type attribute does not apply to nested dirsets - dirsets always implicitly assume type to be dir.
No, default is file
maxparallel Limit the amount of parallelism by passing at most this many sourcefiles at once. Set it to <= 0 for unlimited. Defaults to unlimited. Since Ant 1.6. No
verbose Whether to print a summary after execution or not. Defaults to false. Since Ant 1.6. No

Examples

<chmod file="${dist}/start.sh" perm="ugo+rx"/>

makes the "start.sh" file readable and executable for anyone on a UNIX system.

<chmod file="${dist}/start.sh" perm="700"/>

makes the "start.sh" file readable, writable and executable only for the owner on a UNIX system.

<chmod dir="${dist}/bin" perm="ugo+rx" 
       includes="**/*.sh"/>

makes all ".sh" files below ${dist}/bin readable and executable for anyone on a UNIX system.

<chmod perm="g+w">
  <fileset dir="shared/sources1">

    <exclude name="**/trial/**"/>
  </fileset>
  <fileset refid="other.shared.sources"/>
</chmod>

makes all files below shared/sources1 (except those below any directory named trial) writable for members of the same group on a UNIX system. In addition all files belonging to a FileSet with id other.shared.sources get the same permissions.

<chmod perm="go-rwx" type="file">

  <fileset dir="/web">
    <include name="**/*.cgi"/>
    <include name="**/*.old"/>
  </fileset>

  <dirset dir="/web">
    <include name="**/private_*"/>
  </dirset>
</chmod>

keeps non-owners from touching cgi scripts, files with a .old extension or directories beginning with private_. A directory ending in .old or a file beginning with private_ would remain unaffected.

Source: Apache Ant


 Related Tips

 
< Prev   Next >

Page 1 of 0 ( 0 comments )

You can share your information about this topic using the form below!

Please do not post your questions with this form! Thanks.


Name (required)


E-Mail (required)

Your email will not be displayed on the site - only to our administrator
Homepage(optional)



Comment Enable HTML code : Yes No



 
       
         
     
 
 
 
   
 
 
java bottom left
java bottom middle
java bottom right
RSS 0.91 FeedRSS 1.0 FeedRSS 2.0 FeedATOM FeedOPML Feed

Home - About Us - Privacy Policy
Copyright 2005 - 2008 www.java-tips.org
Java is a trademark of Sun Microsystems, Inc.