## zowe › dbm-db2 › execute › script

Execute a Batch Processor script on a target subsystem. For example, use this command to execute a Batch Processor script or specifically to execute a recovery script to undo changes that were made by the 'zowe dbm execute compare-script' command. If execution of the script fails, you can execute it again using the 'script-section' or 'restart' options. You can edit the script and make changes before you execute or restart it.

For details about command usage for automation, see DBM-Db2 samples at https://github.com/BroadcomMFD/dbm-db2

#### Usage

zowe dbm-db2 execute script <local-input-bp-script-filename> [options]

#### Positional Arguments

- `local-input-bp-script-filename` (string)

  - Specifies the local input file that contains the Batch Processor statements such as the recovery script that was created by executing the 'zowe dbm execute compare-script' command.

#### Options

- `--target-db2` | `--td` (string)

  - Specifies the target Db2 subsystem or data sharing group where you want to execute the script. If this option is not specified, the target subsystem is identified by the first .CONNECT statement in the script.

    Note: If you specify the data sharing group, the first active Db2 subsystem in the group is used.

    The target-db2 option takes precedence over any other value that is specified for the Db2 subsystem or data sharing group.

- `--script-section` | `--ss` (string)

  - Identifies the location in the script where you want to begin execution.

    The following options are valid:

    name - Begin execution of the specific section and process all subsequent statements up to the next section.

    A section is a '.SYSTEM <name>' statement, where <name> identifies a logical grouping of statements such as UNLOADS or SQLDDL. 'source' is an alias for UNLOADS. 'target' is an alias for SQLDDL.

    number - Begin execution after the specific sync point (.SYNC <number> statement) and process all statements up to the end of the script.

    name, number - Begin execution of the specific script section beginning from the sync point (.SYNC <number> statement) within the section and process all subsequent statements up to the next section.

- `--restart` | `-r` (string)

  - Specifies the location in the script where you want to restart execution. The effects of previous successful script statement executions remain.

    The following restart options are valid:

    new - Restart execution of the script at the first statement.

    token - Restart execution of the script at the location that is recorded in the specified token and that was returned from a previous execution failure.

    name, token - Restart execution of the script at the location in the restart section that is recorded in the specified token and that was returned from a prior execution failure.

    A section is a Batch Processor '.SYSTEM <name>' statement, where <name> identifies a logical grouping of statements such as UNLOADS or SQLDDL. 'source' is an alias for UNLOADS. 'target' is an alias for SQLDDL.

- `--error-file` | `--ef` (string)

  - Specifies the local output error file in YAML format. The file contains basic execution information, connection details, dbm-db2 profile parameters, used arguments, and errors that occurred during execution of the command.

    Default value: error.log

- `--modification` | `-m` (string)

  - Specifies a named set of server-managed default parameter values that control the execution behavior of the zowe dbm-db2 commands. For example, you can use a modification to identify a set of default values that differ from the current set of default values.

    For more information about using the modification option, see the DBM Data Service documentation at https://techdocs.broadcom.com/db2mgmt

#### Profile Options

- `--dbm-db2-options-profile` | `--dbm-db2-options-p` (string)

  - The name of a (dbm-db2-options) profile to load for this command execution.

- `--dbm-db2-profile` | `--dbm-db2-p` (string)

  - The name of a (dbm-db2) profile to load for this command execution.

- `--base-profile` | `--base-p` (string)

  - The name of a (base) profile to load for this command execution.

#### DBM-Db2 Connection Options

- `--protocol` (string)

  - Specifies the communication protocol between zowe dbm-db2 client and DBM Data Service.

    Allowed values: http, https

- `--job-cards` | `--jc` (array)

  - Specifies a string array of z/OS JCL JOB statements.

- `--work-dataset-prefix` | `--wdp` (string)

  - Specifies the prefix (high-level qualifier) in z/OS work data set names.

- `--delete-work-datasets` | `--dwd` (boolean)

  - Specifies whether to delete work data sets on a mainframe after the request is fulfilled.

- `--overwrite-output-files` | `--oof` (boolean)

  - Specifies whether to overwrite output files if they exist.

- `--base-path` | `--bp` (string)

  - The base path for your API mediation layer instance. Specify this option to prepend the base path to all DBM DS resources when making REST requests. Do not specify this option if you are not using an API mediation layer.

#### Base Connection Options

- `--host` | `-H` (string)

  - Host name of service on the mainframe.

- `--port` | `-P` (number)

  - Port number of service on the mainframe.

- `--user` | `-u` (string)

  - User name to authenticate to service on the mainframe.

- `--password` | `--pass` | `--pw` (string)

  - Password to authenticate to service on the mainframe.

- `--reject-unauthorized` | `--ru` (boolean)

  - Reject self-signed certificates.

    Default value: true

- `--token-type` | `--tt` (string)

  - The type of token to get and use for the API. Omit this option to use the default token type, which is provided by 'zowe auth login'.

- `--token-value` | `--tv` (string)

  - The value of the token to pass to the API.

- `--cert-file` (local file path)

  - The file path to a certificate file to use for authentication.

    Note: The CLI does not support certificate files that require a password. For more information, search Troubleshooting PEM Certificates in Zowe Docs.

- `--cert-key-file` (local file path)

  - The file path to a certificate key file to use for authentication

#### Examples

- Execute a recovery script:

  - `zowe dbm-db2 execute script recovery.txt`

- Execute a script on the 'TEST' Db2 subsystem:

  - `zowe dbm-db2 execute script script001.txt --target-db2 TEST`

- Execute only the SQLDDL section of a script. The first .CONNECT statement in the script identifies the target subsystem where the script is executed. Execution begins at the .SYSTEM SQLDDL statement and ends at the next .SYSTEM statement in the script:

  - `zowe dbm-db2 execute script script001.txt --script-section SQLDDL`

- Execute a script beginning from the sync point 10 (.SYNC 10 statement) to the end of the script:

  - `zowe dbm-db2 execute script script001.txt --script-section 10`

- Execute only the target (SQLDDL) section of the script starting at sync point 20:

  - `zowe dbm-db2 execute script script001.txt --script-section target,20`

- Restart execution of a script from the beginning:

  - `zowe dbm-db2 execute script script001.txt --restart new`

- Restart execution of a script at the location specified in the token. The restart token is returned by a previous 'zowe dbm execute command' failure as part of the terminal output and in the error file:

  - `zowe dbm-db2 execute script script001.txt --restart 78A724A48DA5185D06FD140F6780D6FA`

- Restart execution at the last successful sync point recorded in the restart token up to the end of the target (SQLDDL) section:

  - `zowe dbm-db2 execute script script001.txt --restart target,78A724A48DA5185D06FD140F6780D6FA`