Understanding Program Type Scripts

A program type is always associated with a program type script. It is the script that does the actual work.

Behind every program type object is a program type script. The program type script performs all the main work of running the program specified in a job definition. Specifically, the program type script accomplishes one or more of the following six tasks:

How a Program Type Script is Executed

When a job is submitted, the agent creates the pm<seq_no>.sh (UNIX) or pm%<seq_no>%.sh (Windows)file and launches the BODY script. After any applicable SYSOUT and PREFIX scripts are run, the BODY script executes the program type script named by the Applications Manager environment variable host_command. This variable holds the name of the program type script. For example, if the SHELLS program type script is used, then host_command will equal SHELLS. This is the section of the BODY script where the actual task is run. The program type script passes the prompts contained in the pr file to the program. All remaining lines of the BODY script deal with evaluating execution requirements, updating statuses, and running COMPLETION, TROUBLE, and SUCCESS scripts.

The steps followed during submittal stages (left to right) and return stages (right to left)

Sample UNIX Program Type Script

Below is a listing of the EXEC program type script. The line numbers have been added for reference and do not appear in the actual script.

1  :

2  #!/bin/sh

3  #copyright 2007 by Automic Software GmbH

4  # $Header:

   /isa/devel/soport/so/dev/sostage/RCS/EXEC-EXECS,v

   1.2 1998/02/24 19:06:46 billw Exp $

5  arg="$program `$SQLOPER_HOME/exec/ONELINE $par`"

6  eval $arg

7  err=$?

8  if [ -f $file ]; then

9       $AW_HOME/exec/FILESIZE $file $err

10      err=$?

11 fi

12 if [ -f $OUTPUT/$file ]; then

13      file=$OUTPUT/$file;export file

14      $AW_HOME/exec/FILESIZE $file $err

15      err=$?

16 fi

17 exit $err

The table below lists the key functions a program type script must perform, and the corresponding lines in the EXEC program.

Function Line(s) Notes

Program execution

6

Accomplished with the eval command. Note that 'arg' includes the $program variable.

Parameter passing

5

Accomplished with ONELINE and $par.

Error determination

7, 10, 15, 17

The code err=$? traps the exit status of the last command executed.

Output registration

9, 14

Accomplished by FILESIZE.

Debug/administration

---

Not present in this script.

Termination

17

Accomplished with exit command. '$err' traps exit code.

Sample Windows Program Type Script

Below is a listing of the EXEC program type script. The line numbers have been added for reference and do not appear in the actual script.

1  @echo off

2  rem Copyright 2007 Automic Software GmbH

3  echo 'In EXECS'

4  echo 'calling'%program%

5  call %SQLOPER_HOME%\bin\oneline %SQLOPER_HOME%\run\%par%

6  call %SQLOPER_HOME%\c\ntspawn "%program% %args%"

7  if errorlevel 1 set err=%errorlevel%

The table below lists the key functions a program type script must perform, and the corresponding lines in the EXEC program.

Function Line(s) Notes

Program execution

6

Accomplished with the ntspawn command.

Parameter passing

5

Accomplished with ONELINE and %par%.

Error determination

7

The code err=%errorlevel% traps the exit status of the last command executed.

Output registration

---

Not present in this script.

Debug/administration

---

Not present in this script.

Termination

---

Not present in this script.