ant调用chmod

摘自ant用户手册 http://ant.apache.org/manual/Tasks/chmod.html

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 Apache Ant 1.6) elements.

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

Starting with Ant 1.7, this task supports arbitrary Resource Collections as nested elements.

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.

By default this task won't do anything unless it detects it is running on a Unix system. If you know for sure that you have a "chmod" executable on your PATH that is command line compatible with the Unix command, you can use the task's os attribute and set its value to your current os.

Parameters

AttributeDescriptionRequired
filethe file or single directory of which the permissions must be changed.exactly one of the two or nested <fileset/list>elements.
dirthe directory which holds the files whose permissions must be changed.
Note: for backwards compatibility reasons <chmod dir="some-dir"/> will only change the permissions on "some-dir" but not recurse into it, unless you also specify any patterns.
permthe new permissions.Yes
includescomma- or space-separated list of patterns of files that must be included.No
excludescomma- or space-separated list of patterns of files that must be excluded. No files (except default excludes) are excluded when omitted.No
defaultexcludesindicates whether default excludes should be used or not ("yes"/"no"). Default excludes are used when omitted.No
parallelprocess all specified files using a single chmod command. Defaults to true.No
typeOne of filedir 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
maxparallelLimit 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
verboseWhether to print a summary after execution or not. Defaults to falseSince Ant 1.6.No
oslist of Operating Systems on which the command may be executed.No
osfamilyOS family as used in the <os> condition.No - defaults to "unix"

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.


【6层】一字型框架办公楼(含建筑结构图、计算书) 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值