Designing a shell script for SMP/E processing

To process a file in a UNIX file system, a shell script must be able to cope with both of the actions that SMP/E can potentially perform on the file: copy and delete. That is, SMP/E can copy the file to a directory in a UNIX file system (as a new file or a replacement for an existing file) and, later, SMP/E can delete the file from a UNIX file system directory. A shell script must be able to detect either of these conditions (copy or delete) and respond accordingly.

Assume, for example, that as part of deleting or replacing a product on your system, you delete a function that was shipped in the product's tar file. SMP/E deletes only the original tar file from the directory in a UNIX file system. It is the responsibility of the shell script to clean up (delete) the tar file's exploded component subdirectories and files.

Fortunately, SMP/E provides shell scripts with the necessary input. This input comes in the form of environment variables that SMP/E sets, as follows:
Variable
Description
SMP_Directory
Directory in a UNIX file system that contains the file to be processed by your shell script. This directory should be considered the working directory for the shell script, and the shell script should not update any directories or files which do not reside within the working directory.
SMP_File
Name of the file to be processed by your shell script. This is the hierarchical file system element processed by SMP/E.
SMP_Action
Action that SMP/E is performing on the file. This value can be either of the following:
COPY
SMP/E is copying the file into a UNIX file system directory.
DELETE
SMP/E is deleting the file from a UNIX file system directory.
SMP_Phase
Point in processing in which SMP/E calls the shell script. This value can be either of the following:
PRE
SMP/E is calling the shell script before performing the action indicated by the SMP_Action variable.
POST
SMP/E is calling the shell script after performing the action indicated by the SMP_Action variable.

SMP_Phase is always set to PRE when SMP_Action is DELETE to ensure that SMP/E calls the shell script before deleting its corresponding element.

LC_ALL
The default value for all of the UNIX locale environment variables. This value is always set to IBM-1047.

IBM-1047 defines the United States English character set. By specifying a specific locale, all shell scripts invoked by SMP/E receive the same environment, regardless of the locale being used on any particular driving system.

PATH
The Java™ runtime directory concatenated with the base PATH value (/bin:.). The Java runtime directory is obtained from either the SMPJHOME DD statement or the SMPJHOME DDDEF entry. The Java runtime directory is required only if the UNIX shell script invokes Java commands.

For example, if the SMPJHOME DD is allocated to "/usr/lpp/java/j1.4", the PATH environment variable value will be set to "/usr/lpp/java/j1.4/bin/:/bin:.".

If neither the SMPJHOME DD statement nor the SMPJHOME DDDEF entry is specified, SMP/E will not set the PATH environment variable.

This input allows you to design a shell script that can respond to SMP/E's actions, as described in the topics that follow.