Chapter 4. Administrator tasks 105
At any point in time, a script may cause the application session to be terminated
unconditionally, for example, when the application is not responding. The
ENDSESS parameter provides this capability.
More complex scripts can be coded where conditional statements may be used
to check values or response times, and the flow of the script may be altered
accordingly. Session Manager provides a number of variables with predefined
meanings. These variables can be used in scripts and panels to provide custom
solutions. See IBM Session Manager for z/OS Panels, Scripts and Variables,
SG34-6288, for detailed descriptions of all Session Manager supplied variables.
4.2.1 Script examples
Below are examples of some script coding techniques for various scenarios.
Example 4-2 on page 106 illustrates code that signs onto a CICS region. It scans
application output looking for specific text before preceding to sign on. Scanning
is accomplished via the OUTSCAN verb. The verb is used in a DO UNTIL
FOUND DO loop. In some situations a script can encounter unsolicited traffic,
such as when an application might send multiple outputs in response to an input.
The DO loop provides a method of accommodating this by looping through its
logic until the required text is found.
When the appropriate text is found, the sign on is accomplished using two
Session Manager variables, t_user and t_pass. These variables hold the user ID
and password used to sign on to Session Manager. The obvious assumption is
that the user ID and password used to sign on to Session Manager will be valid
for a scripted sign on to other applications. If Session Manager is set to connect
to applications that are under the control of a separate security manager, this
could lead to sign-on issues. Sign-on scripts, like the one below, should only be
used on applications that are under the control of the same security manager as
Session Manager.
To prevent the script from going into a permanent wait, the APPLTIME
parameter is used to set a limit for waiting. This wait limit will be the default limit
for all WAITAPPLs and WAITDATAs used in the script. The NORESP statement
can then be used in a script to control actions when the wait time period expires.
In the DO loops of the script below, the IF NORESP THEN statement provides a
method of gaining control after expiration of the wait interval and then logging
information about the script failure and ending the session.
An alternate method of establishing a wait time limit is to specify the TIMEOUT
subparameter on either the WAITAPPL or WAITDATA parameters.
106 IBM Session Manager Implementation
If signon is successful, the Session Manager user variable lc_signon is set to Y.
This user variable is available to any script that calls CICSLOG. It can be
checked and script logic run based on its contents. The CICSLOG script, as
shown below, can be used standalone or called from another script.
Example 4-2 CICSLOG script
Script CICSLOG
APPLTIME 10
AUDITMSG ‘Script CICSLOG started for user &t_user&’
LET lc_signon = ‘N’
DO UNTIL FOUND
IF NORESP THEN
AUDITMSG ‘Script CICSLOG, text SIGN ON not found’
ENDSESS
RETURN
END
WAITAPPL
OUTSCAN ‘SIGN ON’
END
INPUT KEY CLEAR
WAITAPPL
INPUT TEXT ‘CESN’
DO UNTIL FOUND
IF NORESP THEN
AUDITMSG ‘Script CICSLOG, CESN response not found’
ENDSESS
RETURN
END
WAITAPPL
OUTSCAN ‘SIGN’
END
INPUT SBA 10 26 TEXT t_user
SBA 11 26 TEXT t_pass KEY ENTER
WAITAPPL
OUTSCAN ‘DFHCE3449’
IF FOUND THEN LET lc_signon = ‘Y’
ELSE LET lc_signon = ‘N’
END
In the next example, Example 4-3 on page 107, SCRIPT1 issues a call to
CICSLOG and then checks to see if the signon was successful. If the signon
succeeded, the CICS transaction TRN1 is issued and the application response is
checked. Based on what is or is not found in the application response, there can
be one of three outcomes:
If the text MESSAGE8 is found in the application output message, the script
logic simulates the Enter key being pressed and the script ends.
Get IBM Session Manager Implementation now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.