2.6.2 Converting path names
Define the path conversion settings as parameters so that the path names used in job definition scripts can be used in both Windows and UNIX.
In JP1/Advanced Shell, you can specify paths in job definition scripts according to the platform as shown in the following.
Item |
Windows environment |
UNIX environment |
---|---|---|
Directory separator |
\\#1 |
/ |
Path separator |
; |
: |
Capitalization of path name |
Case sensitive#2 |
Case sensitive |
Absolute path |
A path name begins with drive-letter:\\#1, #3 |
A path name begins with / |
- #1
In a Windows environment, use \\ because \ is treated as an escape character. Alternatively, enclose the entire path name in single quotation marks.
- #2
When path names are converted, they are case sensitive also in a Windows environment.
- #3
UNC names are also supported. When you define path name conversion in job definition scripts, make sure that the path obtained after conversion will not end with a shared name (including a name ending with \). If a path name ends with a shared name, operation is not guaranteed.
To convert paths according to the above rules, the following definitions are required in the parameters:
If you want to execute job definition scripts in a Windows environment:
Define / and : so that the separators used in the UNIX environment can be interpreted correctly.
If you want to execute job definition scripts in a UNIX environment:
Define \\ and ; so that the separators used in the Windows environment can be interpreted correctly.
The following explains the parameters used to convert path names.
PATH_CONV_ENABLE parameter
Enables the path conversion functionality. Specify the path separator and directory separator before conversion. In a Windows environment, define / and :. In a UNIX environment, define \\ and ;.
PATH_CONV_RULE parameter (Windows only)
As the path name conversion target, define one of the following:
The range enclosed in double quotation marks is the conversion target (path conversion setting 1)
All text excluding the range enclosed in single quotation marks is the conversion target (path conversion setting 2)
If the parameter is omitted or in UNIX, the path conversion setting 1 is applied, in which case only the range enclosed in double quotation marks is converted.
PATH_CONV parameter
Defines path name character strings before and after conversion. When job definition scripts are executed, path names are converted according to the rules defined in the parameter. Only the range in a path name that is defined by the PATH_CONV_RULE parameter is converted.
If a path name matches the conversion character string defined in the PATH_CONV parameter, path separators and directory separators are also converted.
- Organization of this subsection
(1) Example of file path conversion (path conversion setting 1)
This example shows how job definition scripts before execution are converted according to the information in the environment file.
Information in the environment file
The following shows an example environment file for Windows:
#-adsh_conf PATH_CONV_ENABLE / : #-adsh_conf PATH_CONV_RULE 1 #-adsh_conf PATH_CONV /home/hitachi/bin "C:\\Program Files" <-1. #-adsh_conf PATH_CONV /tmp "C:\\temp" <-2.
Job definition script before execution
#-adsh_path_var DIR,DIR2 "/home/hitachi/bin/myprog1" "/tmp/file" <-1., 2. DIR="/home/hitachi/bin" <-1. "$DIR/myprog1" "/tmp/file" <-2. DIR2=$DIR "$DIR2/myprog2" "/tmp/file" <-2.
Job definition script after execution
The following results when paths have been converted:
"C:\\Program Files\\myprog1" "C:\\temp\\file" <-1., 2. DIR="C:\\Program Files" <-1. "$DIR\\myprog1" "C:\\temp\\file" <-2. DIR2=$DIR "$DIR2\\myprog2" "C:\\temp\\file" <-2.
Path /home/hitachi/bin is converted to C:\\Program Files according to the PATH_CON parameter definition.
Also, the directory separator is converted from / to \\ according to the PATH_CONV_ENABLE parameter definition.
Path /tmp is converted to C:\\temp according to the PATH_CONV parameter definition.
Also, the directory separator is converted from / to \\ according to the PATH_CONV_ENABLE parameter definition.
(2) Example of file path conversion (path conversion setting 2)
This example shows how job definition scripts before execution are converted according to the information in the environment file.
Information in the environment file
The following shows an example environment file for Windows:
#-adsh_conf PATH_CONV_ENABLE / : #-adsh_conf PATH_CONV_RULE 2 #-adsh_conf PATH_CONV /home/user01 d:\\home\\user01 #-adsh_conf PATH_CONV BB/AA BB\\AA
Job definition script before execution
#-adsh_job JOB001 #-adsh_path_var DIR01 echo -E "/home/user01/file" cat /home/user01/file DIR01=/home/user01 cat $DIR01/file02 <-1. PATH=/home/user01/prog:$PATH <-2. uap01 DIR02=/home/user01 PATH="$DIR02:/home/user01/prog:$PATH" AA=10 BB=200 let ANS=BB/AA <-3. echo $ANS cat BB/AA
Job definition script after execution
The following results when paths have been converted:
#-adsh_job JOB001 #-adsh_path_var DIR01 echo -E "d:\\home\\user01\\file" cat "d:\\home\\user01"\\file DIR01="d:\\home\\user01" cat "$DIR01"\\file02 <-1. PATH="d:\\home\\user01"\\prog";""$PATH" <-2. uap01 DIR02="d:\\home\\user01" PATH="$DIR02;d:\\home\\user01\\prog;$PATH" AA=10 BB=200 let ANS="BB\\AA" <-3. echo $ANS cat "BB\\AA"
Because shell variable DIR01 that handles path names is defined in the job definition script before conversion, shell variable DIR01 is enclosed in double quotation marks (") and then a directory separator is added after the shell variable.
Because the top of the character string matches the conversion rule, it is enclosed in double quotation marks ("). The path separator is converted to ";". Furthermore, because the character string was converted to the path, variable name PATH is also enclosed in double quotation marks.
Conversion takes place because the arithmetic expression matches the path conversion setting. To suppress this conversion, the job definition script must be corrected with either of the following methods:
Enclose the variable in single quotation marks such as let ANS='BB/AA'.
Add $ at the beginning of the variable name to be referenced such as let ANS=$BB/$AA.
(3) Notes
If this definition is used to convert path names to obtain Windows path names, the directory separator in path names becomes \. Therefore, if a path name is displayed by the echo command unconditionally in a job definition script, \ and the immediately following character are replaced with the escape character.
If you do not want to replace these characters with the escape character, execute the echo command with the -E option specified. For details, see 9.3.9 echo command (outputs what is specified in arguments to the standard output) in 9.3 Standard shell commands.
The metacharacters ~, ~+, and ~- cannot be replaced if they are enclosed in quotation marks, or if they are specified immediately before an escape character (\) or immediately before a character string enclosed in quotations marks. For the metacharacters, use the corresponding shell variables by referencing 5.1.6 Metacharacters.