Hitachi

JP1 Version 11 JP1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide 


2.2.7 Using hard links and symbolic links

You can create and use hard links and symbolic links with JP1/Advanced Shell. The following link files can be used with JP1/Advanced Shell:

Hereafter, the UNIX edition and Windows edition are described separately.

Organization of this subsection

(1) UNIX edition

In the UNIX edition of JP1/Advanced Shell, hard links and symbolic links can be created by using the UNIX-compatible ln command and commands provided by the OS, and these links can be used in the job definition script.

(2) Windows edition

(a) Files and folders that support hard links and symbolic links

In the Windows edition of JP1/Advanced Shell, you can create hard links and symbolic links by using the UNIX-compatible ln command and commands provided by the OS. The following files and folders support hard links and symbolic links:

  • Files and folders handled by UNIX-compatible commands and standard shell commands

  • Files specified for the redirect symbol

  • Files and folders specified by using file attributes of conditional expressions

Do not create hard links and symbolic links for the following files and folders.

  • Various commands provided by JP1/AS

  • Files and folders created when installing JP1/AS

  • Job definition script file

  • External script file

  • Initialization script file

  • Script file executed by the child job

  • Files and folders under the spool directory

  • Files and folders under the temporary file directory

  • Files and folders under the trace directory

  • Files and folders under the log directory

  • Environment file

(b) Points to be checked before using symbolic links

Check the following points in advance when using symbolic links.

  • When creating, deleting, moving or copying a symbolic link, execute the operation as a user having the administrative role for creating symbolic links. A user who does not have the necessary permissions to create symbolic links cannot perform operations involving symbolic links. In addition, even users having the administrative role for creating symbolic links cannot create a symbolic link in an environment where user account control (UAC) has been enabled. To create a symbolic link in an environment where UAC has been enabled, you need to grant the administrator privilege to a user having the administrative role for creating symbolic links.

  • Before using symbolic links, confirm whether the target machine is permitted to use symbolic links. For details on how to check whether the use of symbolic links is permitted, see the manual for Windows.

(3) Notes

Note the following when using hard links and symbolic links:

(a) Notes common to all platforms

  • In the name of a link file, do not use the same name as a command provided by JP1/Advanced Shell.

  • The behavior when the number of times a symbolic link file is nested exceeds the upper limit of the OS will be in accordance with the specifications of each OS.

  • Multiple hard links can be created for a single file. However, the maximum number of hard links that can be created for a single file depends on the OS or file system. Note that creation of a hard link fails when the maximum number has been exceeded.

(b) Notes for the UNIX edition

You cannot specify a hard link or symbolic link as the output destination for the coverage information file (asc file). If a hard link or symbolic link is specified, the behavior is as follows.

  • If a symbolic link is specified as the output destination for the asc file, the symbolic link is deleted and a normal file having the same name is created.

  • Coverage information of the asc file is not updated even if the asc file is updated while multiple hard links are created for a single asc file.

(c) Notes for the Windows edition

  • Link files cannot be created in a file system other than NTFS.

  • Symbolic links might not work in an environment where a product designed for protecting the file system is installed. When using symbolic links, make sure the installed product supports symbolic links.

  • When starting an executable file by using a symbolic link, the extensions of both the symbolic link and the executable file must be one of the following: ".bat", ".com", ".cmd", or ".exe". However, as the following formats conform to specifications of the execution program starting the executable file, determination of the execution role is also subject to the specifications of the execution program.

    • system function of the awk command

    • Format of the awk command: command-name | getline [variable name]

    • Format of the awk command: print [expression [, ... ]] | command-name

    • -exec and -ok primaries of the find command

    • xargs command

  • When accessing a file or folder by using a symbolic link, the access privilege of the link destination needs to be followed. When accessing the symbolic link itself, the access privilege of the link destination needs to be followed.

  • If the link destination of a symbolic link to a directory is a normal file or the link destination of the symbolic link to a file is a directory, the link destination cannot be accessed and an error occurs.

  • As a result of the support for link files, information related to link files is output. Accordingly, part of the output format of UNIX-compatible commands including the ls command have been changed. If you want to return the output format to a version earlier than 11-00 without using link files, specify L0 for the environment variable ADSH_LINK_SUPPORT.

(4) Environment variable ADSH_LINK_SUPPORT (defining the link support level of JP1/Advanced Shell)

In JP1/Advanced Shell, hard links and symbolic links can be used from 11-00. However, part of the output format and output content in addition to the results have changed as a result of the support for hard links and symbolic links. Users who have been using JP1/Advanced Shell of a version earlier than 11-00 and who will not be using link files will need to consider the specification of the environment variable ADSH_LINK_SUPPORT.

(a) Values that can be set for environment variable

The following values can be specified for the environment variable ADSH_LINK_SUPPORT:

Table 2‒14: Values that can be specified for the environment variable ADSH_LINK_SUPPORT

Value

Meaning

L0

Hard links and symbolic links cannot be used.

The main changes when L0 is specified are as follows.

  • The number of hard links is not output by the find command, ls command, or stat command.

  • Options related to UNIX-compatible commands and standard shell commands are ignored even when they are specified.

  • The -L option of the adshscripttool command is not available.

  • If you use the operators -h, -L, and -ef (which determine the file attribute) without specifying the environment setting parameter UNSUPPORT_TEST, the job ends in an error.

L1

Hard links and symbolic links can be used with the following functions:

  • UNIX-compatible commands

  • Standard shell commands

  • Conditional expressions of file attributes

  • Redirects to files

Other than the above

Jobs and commands are not executed, and processing ends in an error.

The difference between the output formats when L0 and L1 are specified for the environment variable ADSH_LINK_SUPPORT is shown below, by using the ls command as an example.It is assumed that the path to the directory in which the ls command is installed is stored in the environment variable OSCMD_DIR.

  • For L0:

    C:\TEMP>%OSCMD_DIR%\ls -l 
    total 439744
    -rw------- Administrators  102000 Jul 06 16:26 HARDLINK.txt
    -rw------- Administrators  102000 Jul 06 16:20 SYMLINK.txt
    drwx------ Administrators         Jul 06 16:58 TestLog
    -rw------- Administrators  102000 Jul 06 16:20 test_data.txt
    -rw------- Administrators  102000 Jul 06 16:26 test_result.txt
    -rwx------ Administrators   31744 Jun 12 16:23 uap.exe
  • For L1:

    C:\TEMP>%OSCMD_DIR%\ls -l
    total 337744
    -rw------- 2 Administrators  102000 Jul 06 16:26 HARDLINK.txt
    lrw------- 1 Administrators       0 Jul 06 16:27 SYMLINK.txt -> .\test_data.txt
    drwx------ 1 Administrators         Jul 06 16:58 TestLog
    -rw------- 1 Administrators  102000 Jul 06 16:20 test_data.txt
    -rw------- 2 Administrators  102000 Jul 06 16:26 test_result.txt
    -rwx------ 1 Administrators   31744 Jun 12 16:23 uap.exe

(b) Notes

  • If the environment variable ADSH_LINK_SUPPORT is not defined, the command is executed by assuming that L1 was specified.

  • Specify either L0 or L1 for the environment variable ADSH_LINK_SUPPORT. When a value other than L0 and L1 is specified, jobs and commands are terminated end in an error with return code 255.

  • The environment variable ADSH_LINK_SUPPORT is available with the Windows edition. This environment variable is not available with the UNIX edition.

  • If you prepare settings by using a job definition script file or environment file, such settings will only be valid for child jobs that start from a job definition script, root jobs, the execution of other processes, and some UNIX-compatible commands.