CHGCURDIR (Change Current Directory)

CHGCURDIR Command syntax diagram

 

Purpose

The Change Current Directory (CHGCURDIR) command changes a specified directory to the current working directory. The current directory can be a directory, library, folder, or database file. The current directory is used to locate objects used by the commands.

This command can also be issued using the following alternative command names:

For more information about integrated file system commands, see Integrated file system topic in the File systems and management category of the Information Center.

 

Restrictions

  1. This command works on only one object. If a pattern is specified on the OBJ parameter and more than one object matches the pattern, you can select the object from a list in an interactive job. If this is a batch job, the command fails with the error message CPFA08E, "More than one name matches pattern."

  2. The current directory and current library are separate and distinct entities. Set the current library and current directory to be the same library, but a change to either the current library or current directory does not affect the other.

    The current directory, top with this command, affects the integrated file system commands and POSIX APIs. The current library, set with the Change Current Library (CHGCURLIB) command, affects commands such as the Create Display File (CRTDSPF) command, that uses the value *CURLIB as a library qualifier.

  3. The user must have *X authority to the directory and each directory in the path.

 

Required Parameters

DIR
Specifies the path name of the directory that replaces the current working directory of the job. See path names for more information on specifying path names.

Examples for CHGCURDIR

Example 1: Changing a Current Directory

CHGCURDIR   DIR(DIRECTORY2)

This command changes the current directory to the directory named DIRECTORY2 in the current directory.

Example 2: Changing a Current Directory to the Parent of the Current Directory

CHGCURDIR   DIR('..')

This command changes the current directory to the parent directory or the directory that contains the current directory before this command is run.

Error messages for CHGCURDIR

*ESCAPE Messages

CPFA085
Home directory not found for user &1.
CPFA08E
More than one name matches pattern.
CPFA093
Name matching pattern not found.
CPFA09C
Not authorized to object.
CPFA09D
Error occurred in program &1.
CPFA0A1
An input or output error occurred.
CPFA0A3
Path name resolution causes looping.
CPFA0A7
Path name too long.
CPFA0A9
Object not found.
CPFA0AB
Object name not a directory.