EXEC

Read syntax diagramSkip visual syntax diagram EXec1 fn args
Notes:
  • 1 Keyword EXEC may be omitted as long as SET IMPEX is set on.

Authorization

General User

Purpose

Use the EXEC command to execute one or more CMS commands or exec control statements contained in a specified REXX, CMS EXEC, or EXEC 2 file.

Operands

EXec
this keyword may be omitted if you are executing the exec procedure from the CMS command environment and have not issued the command SET IMPEX OFF. (SET IMPEX ON, the default, means CMS treats exec files as commands, making it unnecessary for you to use the EXEC command to execute them.)
fn
is the file name of a file containing one or more CMS commands or EXEC control statements to be executed. The file type of the file must be EXEC. The file can have either fixed- or variable-length records with a logical record length not exceeding 130 characters. A text editor or a user program can create exec files. Exec files a CMS editor creates have, by default, variable-length, 80-character records.
args
are any arguments you choose to pass to the exec. The CMS EXEC processor assigns arguments to special variables &1 through &30 in the order in which they appear in the argument list. The EXEC 2 processor assigns arguments to special variables starting with special variable &1. With the REXX and the EXEC 2 processors, the number of arguments is not limited. However, the number of bytes of data you can pass in the argument list is limited. The limit is the maximum number of bytes that can fit in a line: 130 bytes if the command is entered from a terminal, 255 bytes if the command is issued from a program. Arguments passed to REXX are handled differently from the way they are in EXEC or EXEC 2. For more information, see z/VM: REXX/VM Reference.

For information on REXX, see z/VM: REXX/VM Reference and z/VM: REXX/VM User's Guide.

For information about EXEC 2 control statements, use the HELP facility to get complete descriptions of EXEC and EXEC 2 control statements, special variables, and built-in functions by entering:
help exec menu
or
help exec2 menu

Examples

If the implied EXEC function is set to OFF (QUERY IMPEX to find out the setting), and if you want to execute your SQUARE EXEC (which squares a number), enter:
exec square 4
If IMPEX is on, you can simply enter:
square 4

For more examples on using the EXEC command, see z/VM: CMS User's Guide.

Responses

The amount of information displayed during the execution of a CMS EXEC depends on the setting of the &CONTROL control statement. By default, &CONTROL displays all CMS commands, responses, and error messages. In addition, it displays nonzero return codes from CMS in the format:
+++ R(nnnnn)  +++
Where:
nnnnn
specifies the return code from the CMS command.
The amount of information displayed during the execution of:
  • A REXX file depends on whether tracing is set on. For more information, see z/VM: REXX/VM Reference.
  • An EXEC 2 file depends on the setting of the &TRACE control statement. For more information about &TRACE is available through the z/VM Help Facility by entering:
    help exec2 &trace

Return codes for error messages from CP commands directly correspond to the message number. For example, if you issued a CP LINK command with an incorrect user ID, you receive error message HCPLNK053E userid not in CP directory. When issued from a CMS EXEC program, the same CP LINK command would have a return code of 53.

Messages and Return Codes

  • DMS175E Invalid EXEC command RC=10000
  • DMS255T Insufficient storage for Exec interpreter RC=10096
  • DMS240E Alternate exec processor name not found RC= -3
  • DMS240E Unable to load the CMS exec processor "DMSEXT" RC= -3
  • DMS639E Error in routine-name routine; return code was nn
  • DMS1229E fileid is empty [RC=88]
  • DMS042E No execid specified [RC=24]
If the CMS EXEC interpreter finds an error, it displays the message:
DMS072E  Error in EXEC file fn, line nnn:
message

The possible errors, and the associated return codes, are:

Description Return Code
FILE NOT FOUND 801
&SKIP OR &GOTO ERROR 802
BAD FILE FORMAT 803
TOO MANY ARGUMENTS 804
MAX DEPTH OF LOOP NESTING EXCEEDED 805
ERROR READING FILE 806
INVALID SYNTAX 807
INVALID FORM OF CONDITION 808
INVALID ASSIGNMENT 809
MISUSE OF SPECIAL VARIABLE 810
ERROR IN &ERROR ACTION 811
CONVERSION ERROR 812
TOO MANY TOKENS IN STATEMENT 813
MISUSE OF BUILT-IN FUNCTION 814
EOF FOUND IN LOOP 815
INVALID CONTROL WORD 816
EXEC ARITHMETIC UNDERFLOW 817
EXEC ARITHMETIC OVERFLOW 818
SPECIAL CHARACTER IN VARIABLE SYMBOL 819
If the EXEC 2 interpreter finds an error, it displays the message:
DMS085E  Error in fn ft fm, line nnn - message

The possible errors and the associated return codes related to this message are:

Description Return Code
FILE NOT FOUND 10001
WRONG FILE FORMAT 10002
WORD TOO LONG 10003
STATEMENT TOO LONG 10004
INVALID CONTROL WORD 10005
LABEL NOT FOUND 10006
INVALID VARIABLE NAME 10007
INVALID FORM OF CONDITION 10008
INVALID ASSIGNMENT 10009
MISSING ARGUMENT 10010
INVALID ARGUMENT 10011
CONVERSION ERROR 10012
NUMERIC OVERFLOW 10013
INVALID FUNCTION NAME 10014
END OF FILE FOUND IN LOOP 10015
DIVISION BY ZERO 10016
INVALID LOOP CONDITION 10017
ERROR RETURN DURING &ERROR ACTION 10019
ASSIGNMENT TO UNSET ARGUMENT 10020
STATEMENT OUT OF CONTEXT 10021
INSUFFICIENT STORAGE AVAILABLE 10097
FILE READ ERROR nnn 10098
TRACE ERROR nnn 10099

For more information on the possible errors and associated return codes for REXX, see z/VM: REXX/VM Reference.

Additional system messages may be issued by this command. The reasons for these messages and their location are:

Reason Location
Errors in the Shared File System File Pool Server Messages