HP 3000 Manuals

Job and Session Variable Information [ Getting System Information Programmer's Guide ] MPE/iX 5.0 Documentation


Getting System Information Programmer's Guide

Job and Session Variable Information 

You can use various MPE commands to display the variables in effect for a
specific job or session.  These variables include job control words
(JCWs), which are a type of variable.

Variables fall into two categories:  user-defined and predefined.
User-defined variables (which can also include JCWs) are those that you
define within your job or session.  Predefined variables are defined for
you by the system when you start a job or session.  You can change some
of the predefined variables, including certain JCWs, within your job or
session.  Those you cannot change are READONLY variables (sometimes
called system-reserved variables).

For a list of the predefined variables available in MPE/iX, refer to
the Command Interpreter Access and Variables Programmer's Guide 
(32650-90011).  This manual also explains how to set and use variables
and JCWs.

Besides using commands and intrinsics to identify variables, you can use
the variables themselves to obtain various kinds of system information.
MPE/iX permits you to use predefined variables in a command file, as well
as accessing them from the CI.

Displaying current job/session variables with SHOWVAR 

This command displays names of variables and their values for the current
job or session.  If you enter it without parameters, SHOWVAR gives a list
of all variables (including JCWs), currently in effect, that the user has
set.  You can enter a variable name as a parameter, and the value of that
variable will be shown; you can also enter a list of variable names,
separated by commas.

A "wildcard" character, @, may also be used in a variable name to signify
"zero or more alphanumeric or underbar characters." Entered by itself, @
shows a list of all variables currently in effect, including predefined
variables.

Other wildcard characters that can be used in variable name parameters
include:

     # = one numeric character.

     ? = one alphanumeric character.

     [ ] = a set or range of characters that can appear anywhere
           in the name; this set is not case sensitive.

The following examples illustrate the use of SHOWVAR.

     :SHOWVAR CIERROR, HPMSGFENCE 
     CIERROR = 976
     HPMSGFENCE = 0

     :SHOWVAR @JOBS 
     HPWAITJOBS = 2

     :SHOWVAR [A-F]@ 
     CIERROR = 976

Displaying job control words with SHOWJCW 

A job control word (JCW) is an integer variable that falls within the
range of 0...65,535.  You can set a predefinedword named JCW by using the
SETJCW intrinsic or the SETJCW command.  (Because a JCW is a type of
variable, you can also set it by using the HPCIPUTVAR intrinsic or the
SETVAR command.)  Other job control words are read only; for example,
HPDATE is a predefined variable that you cannot reset.  Finally, you can
establish user-defined job control words with the SETJCW command or the
PUTJCW intrinsic.

All these JCWs can be displayed by using the SHOWJCW command.  This
command, entered without parameters, displays user-defined and predefined
read/write JCWs.  You can also enter the JCW name as a parameter to see
the value of a specific JCW. The read only JCWs are displayed only if you
enter the JCW name.


NOTE The SHOWJCW command displays only JCWs, that is, variables that were defined specifically as a JCW by use of the JCW commands or intrinsics. The SHOWVAR command displays all variables currently in effect, including any JCWs.
The following examples illustrate the use of SHOWJCW: :SHOWJCW JCW = 0 CIERROR = 975 :SHOWJCW HPDATE HPDATE = 9 SYSTEM RESERVED JCW Searching for JCWs with FINDJCW This intrinsic searcheword (JCW). It returns the value of either type of JCW, user-defined or predefined. There are three required parameters: jcwname Name of the JCW to be found. Can contain up to 255 alphanumeric characters, starting with a letter and delimited by a nonalphanumeric character. jcwvalue Returns the value of jcwname, if found; if not, jcwvalue is unchanged. status The results of the intrinsic call: 0 = Successful 1 = Error, jcwname more than 255 characters long. 2 = Error, jcwname does not start with a letter. 3 = Error, jcwname not found in JCW table. 4 = Error, attempted to assign a value to an MPE/iX-defined JCW value mnemonic (OK, WARN, FATAL, or SYSTEM). 5 = Error, cannot assign a value to a system-reserved JCW. Returning JCW value with GETJCW This intrinsic is used to obtain the value of the JCW, and return it to the calling process. The GETJCW intrinsic is used after the value of JCW has been set by the calling process using SETJCW or PUTJCW. There are no parameters. The form of the intrinsic call is: JCW:=GETJCW; The value of the job control word is returned in JCW. Returning variable value with HPCIGETVAR This intrinsic is used to retrieve the value and/or attributes of a specified variable from the session variable table. The intrinsic call could be HPCIGETVAR (varname, status, keyword, keyvalue) The required parameter varname passes the name of the variable whose value is to be retrieved. The optional status parameter returns an error code if the variable's value can not be retrieved.
NOTE Although the status parameter is optional, not specifying it causes the calling process to abort if an error is encountered. This is a feature of MPE/iX designed to prevent undetected errors.
The keyword parameter passes a number indicating the variable attribute that you wish to retrieve. The value of that attribute is returned in keyvalue. You can specify up to six keyword,keyvalue pairs. For a list of the status codes and keyword,keyvalue codes available for this intrinsic, refer to the MPE/iX Intrinsics Reference Manual (32650-90028). Programmatic use of predefined variables MPE/iX permits you to use predefined variables programmatically as well as through the CI. The following examples show simple uses of this feature. Example: Using predefined variables to add capabilities. Example 3-4 illustrates a command file that allows the user to add a capability, and checks whether the user already has the specified capability. Use of this command file is illustrated in example 3-5. ____________________________________________________________________ | | | | | PARM cap | | COMMENT Syntax: addcap <capability> | | COMMENT Adds "cap" to the current user's existing | | COMMENT capabilities. Must have 'AM' to execute :ALTUSER. | | COMMENT New capabilities in effect after user re-logs on. | | COMMENT: Tests first that user doesn't have 'cap' already. | | if pos(ups('!cap'),hpusercapf) > 0 then | | echo (ADDCAP): You already have ![ups('!cap')]. | | else | | setvar cierror 0 | | continue | | altuser !hpuser;cap=![hpusercapf+',!cap'] | | if cierror <> 0 then | | echo (ADDCAP): Your capabilities remain: !hpusercapf. | | else | | echo (ADDCAP): Your new capabilities are: & | | ![hpusercapf+','+ups('!c | | setvar addcap_temp 'N' | | continue | | input addcap_temp, & | | '(ADDCAP): Log off/on now (Y/N) ==>',10 | | if cierror = 9003 then | | echo (ADDCAP): Timed 10-second read expired. & | | Logon cancelled. | | else | | if ups(lft(addcap_temp,1)) <> 'Y' then | | echo (ADDCAP): New capabilities take effect & | | at next logon. | | else | | hello !hpjobname,!hpuser.!hpaccount,!hpgroup | | endif | | deletevar addcap_temp | | endif | | endif | | endif | | | ____________________________________________________________________ Example 3-4. Adding Capabilities - Command File ________________________________________________________________ | | | | | :listuser foo | | ******************** | | USER: FOO.UI | | | | HOME GROUP: CI PASSWORD: ** | | MAX PRI : 150 LOC ATTR: $00000000 | | LOGON CNT : 1 | | CAP: AM,ND,SF,BA,IA | | | | :addcap ba | | (ADDCAP): You already have BA. | | | | :addcap al | | (ADDCAP): Your new capabilities are: AM,ND,SF,BA,IA,AL | | (ADDCAP): Log off/on now (Y/N) ==> n | | (ADDCAP): New capabilities take effect at next logon. | | | | :addcap al | | (ADDCAP): Your new capabilities are: AM,ND,SF,BA,IA,AL | | (ADDCAP): Log off/on now (Y/N) ==> y | | CPU=10. CONNECT=71. WED, MAY 6, 1987, 12:44 PM. | | HP3000 / MPE/iX A.01.00. WED, MAY 6, 1987, 12:45 PM. | | | ________________________________________________________________ Example 3-5. Result of Using Adding Capabilities Command File Example: Using predefined variables to check file existence. The following examples show you how to use various predefined variables to obtain system information. In the first program fragment, you use CIERROR to test whether a specified file exists: setvar cierror 0 continue listf filename;$null if cierror <> 0 then COMMENT: if cierror is not 0, assume file does not exist. In this example, you could use SETJCW instead, since CIERROR is a job control word. Example: Using FINFO to check file existence. Note that you can also use the Finfo expression evaluator to do the same thing, for example: if finfo("filename","exists") then comment: item # 0 is a test for the existence of a file. Example: Using JCW to test for fatal error. In the second example, you use the system Job Control Word named JCW to test why a program failed, and print a message if a fatal error occurred: continue run program if jcw >= fatal then COMMENT: fatal error occurred ('fatal' is a reserved word) tell usr.acct Program encountered a fatal error!


MPE/iX 5.0 Documentation