Hitachi

Job Management Partner 1 Version 10 Job Management Partner 1/Advanced Shell Description, User's Guide, Reference, and Operator's Guide


5.9.2 Allocating temporary files and performing postprocessing

You use the #-adsh_file_temp command to create a file that will be used temporarily within the job definition script and then assign its file path to a shell variable or environment variable. The allocated temporary file is deleted when the job terminates.

Organization of this subsection

(1) Allocating temporary files

Create a file that will be used temporarily within the job definition script and then allocate its file path to a shell variable or environment variable that has the same name as the specified file environment variable definition name.

There are two ways to allocate temporary files:

(a) Creating and allocating temporary files

Specify create for the chk attribute. The size of the file to be created is zero bytes. In UNIX, the permission for a created temporary file depends on the umask value for the file owner (creator) part and is always 0 for the group and other users' access permission part. In Windows, no file permission is specified.

To use a temporary file allocated within a job step also in subsequent job steps, specify a temporary file identifier and keep for the normal attribute.

If a temporary file allocated within a job step is not to be used in subsequent job steps or is to be specified outside the job step, specify del for the normal attribute.

To allocate a temporary file outside the job step, neither a temporary file identifier nor normal keep can be specified.

(b) Allocating existing temporary files

Specify exist in the chk attribute and the temporary file identifier specified in the earlier job step.

It is not permissible to specify the name of a temporary file that was not created in a preceding job step or a temporary file that was deleted during postprocessing of the preceding job step.

To use an allocated temporary file in a subsequent job step, specify keep for the normal attribute.

To not use an allocated temporary file in subsequent job steps, specify del for the normal attribute.

(2) Postprocessing of temporary files

Temporary files are postprocessed when the job step or job that allocated the files terminates. Postprocessing involves resetting the shell and environment variables in which the file path is set to their previous values before the file path was set. Also, the processing described below is performed according to the termination status of the job step or job and the normal attribute value.

If the job step and job terminated normally:
  • If keep is specified for the normal attribute, the temporary files are not deleted when the job step terminates. If keep is specified for the normal attribute, but the temporary files were not used in subsequent job steps, the temporary files are deleted when the job terminates.

  • If del is specified for the normal attribute, the temporary files are deleted when the job step or job terminates.

If the job step and job terminated with an error:
  • If keep is specified for the normal attribute, the temporary files are deleted when the job terminates, not when the job step terminates.

  • If del is specified for the normal attribute, the temporary files are deleted when the job step or job terminates.

(3) Names of temporary files

The names of temporary files are different in Windows and in UNIX. The following shows the file names used in these OSs.

In Windows

The name of a temporary file consists of the system-specific character string ASH and a name unique in the directory.

ASHunique-name.tmp
In UNIX

The name of a temporary file consists of the character string TEMP indicating a temporary file, the job name, a temporary file identifier, and a name unique in the directory.

  • Temporary file name with a temporary file identifier specified

    TEMP_job-sequence-number_job-name_temporary-file-identifier_unique-name

  • Temporary file name with a temporary file identifier omitted

    TEMP_job-sequence-number_job-name_unique-name

(4) Storage directory

You use the TEMP_FILE_DIR environment setting parameter to specify the directory in which temporary files are to be created. If the environment setting parameter is omitted, the default value for the TEMP_FILE_DIR parameter is used. For details about the TEMP_FILE_DIR parameter, see TEMP_FILE_DIR parameter (defines the path name of the directory for storing temporary files) in 7. Parameters Specified in the Environment Files.

(5) Examples of usage of temporary files

The following presents examples of the usage of temporary files when temporary files are allocated.

(6) Using temporary files to code input files for a program in a job definition script

If you specify a user program's parameters in a temporary file and use the temporary file as the standard input, you can directly specify the parameters in the job definition script and automatically create and delete the temporary file. The following shows an example:

#-adsh_step_start
#-adsh_file_temp SYSIN -id parmfile -chk create -normal keep
cat << @@@ > ${SYSIN}
-in /files/indata
-out /files/outdata
-work /tmp
@@@
uap  ${SYSIN}
#-adsh_step_end

This example creates a temporary file and loads multiple lines of character strings specified in the job definition script by using a here document. The user program uses the temporary file as the standard input during execution and deletes the temporary file once execution is completed.