DEBUG/Administration and Termination

By adding code for debugging, Applications Manager can assist if errors occur during task execution. When a script terminates, it should trap errors, delete old output files, and delete unneeded files created by the program.

DEBUG/Administration

Code should be included in the program type script that will allow for debugging should errors occur within the program. Useful expressions include those that list the values of environment variables currently set, each of the commands actually executed, current times to see where a program type script is, and structures to check the existence of a file containing a program to be run. Applications Manager program type scripts generally include some or all of the commands listed in the following table.

Command/Structure Purpose/Function

UNIX: set -x

Windows: @echo on

Writes commands and arguments as executed to SYSOUT.

UNIX: set or env

Windows: set

Writes the values of all environment variables to SYSOUT.

UNIX: echo $0 `date`

Windows: date /t

Writes the current command and current time.

UNIX: if [ -f $program.sql ];

      then err=0

Windows: if exists %program%.sql

         set err=0

Checks for the existence of the file program.sql and sets the variable err equal to 0 if found.

You can control whether the above commands are active by including code that searches for the Applications Manager DEBUG file as shown in the following script:

UNIX:

if [ "$DEBUG" = "YES" ]; then

        env

        set -x

        echo "in $0"

fi

Windows:

if "%DEBUG%" = "YES" set

if "%DEBUG%" == "YES" @echo on

In the UNIX code, $0 returns the name of the program or script.

Activating DEBUG

You activate DEBUG by creating an empty file called DEBUG in the run directory under AW_HOME by issuing the touch DEBUG command. When DEBUG is active, it applies to all jobs that are run.

Viewing the Log

To view the output log, go to the out directory and find the most recent 'o' file. It should be larger than any of the other output files. The number associated with the 'o' file is the run ID number. This will help you to find the right output for the right task.

Canceling Debug

After you have obtained the log file you need, remove the DEBUG file from the run directory.

Termination

When a script terminates, it should: