8.5.2 chmod command (changes the file read-only attribute setting (enable or disable))
Syntax
chmod [-fhR] mode path-name
You can create this command by using the script_chmod1 sample script file as the base. For details about how to create the command, see (2) Preparations for using the script-format UNIX-compatible commands (Windows only).
Description
This command changes the file read-only attribute setting (enable or disable).
Use this command when you want to suppress updating of files.
Arguments
- -f
Ignores the specification.
- -h
Ignores the specification.
- -R
Ignores the specification.
- mode
Specifies the mode as a symbol or a numeric value and enables or disables the read-only attribute. The table below explains how to specify this option. If any other mode is specified, the command outputs chmod: invalid file mode: mode to the standard error output, in which case the access permissions remain unchanged.
Specification
Symbol
Numeric value
Disabling the read-only attribute and permitting write operations
(equivalent to when the execution results of the adshscripttool -fmode -s w command are AAA or RRR)
+w specified
Numeric value that turns on write permission mode bits u, g, and o (such as 777, 666, 333, 222, and 733)
Enabling the read-only attribute and prohibiting write operations
(equivalent to when the execution results of the adshscripttool -fmode -s w command are DDD)
-w specified
Numeric value that turns off write permission mode bits u, g, and o (such as 555, 444, 111, 000, and 511)
- path-name
Specifies the target file. You can specify multiple files. A folder cannot be specified.
Return code
Return code |
Meaning |
---|---|
0 |
Normal termination |
1 or greater |
Error termination |
Notes
If the executing user does not have permissions to change the file attribute, the attrib command outputs the message Access denied - path-name to the standard error output and then results in an error, in which case the permissions cannot be changed. Grant the executing user the permissions to change file attributes and then re-execute the command.
If a folder is specified for path-name, the message chmod: cannot access [path-name]: change for the directory is not supported is output. In this case, the command does not change the folder read-only attribute and terminates with return code 1.
-
If symbolic link is specified for the argument path name, you can change the link destination file. Use the command provided by OS if you change the symbolic link itself.
Examples
The following shows example definitions of job definition scripts. These examples assume that the chmod command has been created by using the script_chmod1 sample script file as the base.
Use a symbol to prohibit write operations on files:
chmod -w test.txt
Use a symbol to permit write operations on files:
chmod +w test.txt
Use a numeric value to prohibit write operations on files:
chmod 444 test.txt
Specify a mode whose specification is not permitted:
chmod -r test.txt
In this example, the following message is output to the standard error output:
chmod: invalid file mode: -r