Using Zowe CLI
Using Zowe CLI
This section contains information about using Zowe CLI.
#
Displaying Zowe CLI helpZowe CLI contains a help system that is embedded directly into the command-line interface. When you want help with Zowe CLI, you issue help commands that provide you with information about the product, syntax, and usage.
#
Displaying top-level helpTo begin using the product, open a command line window and issue the following command to view the top-level help descriptions:
zowe --help
Tip: The command zowe
initiates the product on a command line. All Zowe CLI commands begin with zowe.
#
Displaying command group, action, and object helpYou can use the --help
global option get more information about a specific command group, action, or object. Use the following syntax to display group-level help and learn more about specific command groups (for example, zos-jobs and zos-files):
zowe <group, action, or object name> --help
zowe zos-files create --help
#
Zowe CLI command reference guideView the CLI Command Reference Guide for a detailed documentation on commands, actions, and options in Zowe CLI. The reference document is based on the @lts-incremental
version of the CLI.
#
Zowe CLI command groupsZowe CLI contains command groups that focus on specific business processes. For example, the zos-files
command group
provides the ability to interact with mainframe data sets. This article provides you with a brief synopsis of the tasks that you can perform with each group. For more information, see Display Zowe CLI Help.
The commands available in the product are organized in a hierarchical structure. Command groups (for example, zos-files
) contain actions (for example, create
) that let you perform actions on specific objects (for example, a specific type of data set). For each action that you perform on an object, you can specify options that affect the operation of the command.
Important! Before you issue these commands, verify that you completed the steps in Create a Zowe CLI profile and Test Connection to z/OSMF to help ensure that Zowe CLI can communicate with z/OS systems.
Zowe CLI contains the following command groups:
#
pluginsThe plugins command group lets you install and manage third-party plug-ins for the product. Plug-ins extend the functionality of Zowe CLI in the form of new commands.
With the plugins command group, you can perform the following tasks:
- Install or uninstall third-party plug-ins.
- Display a list of installed plug-ins.
- Validate that a plug-in integrates with the base product properly.
Note: For more information about plugins
syntax, actions, and options, open Zowe CLI and issue the following
command:
zowe plugins -h
#
profilesThe profiles command group lets you create and manage profiles for use with other Zowe CLI command groups. Profiles allow you to issue commands to different mainframe systems quickly, without specifying your connection details with every command.
With the profiles command group, you can perform the following tasks:
- Create, update, and delete profiles for any Zowe CLI command group that supports profiles.
- Set the default profile to be used within any command group.
- List profile names and details for any command group, including the default active profile.
Note: For more information about profiles
syntax, actions, and options, open Zowe CLI, and issue the following command:
zowe profiles -h
#
provisioningThe provisioning command group lets you perform IBM z/OSMF provisioning tasks with templates and provisioned instances from Zowe CLI.
With the provisioning command group, you can perform the following tasks:
- Provision cloud instances using z/OSMF Software Services templates.
- List information about the available z/OSMF Service Catalog published templates and the templates that you used to publish cloud instances.
- List summary information about the templates that you used to provision cloud instances. You can filter the information by application (for example, DB2 and CICS) and by the external name of the provisioned instances.
- List detail information about the variables used (and their corresponding values) on named, published cloud instances.
Note: For more information about provisioning syntax, actions, and options, open Zowe CLI and issue the following command:
zowe provisioning -h
#
zos-consoleThe zos-console command group lets you issue commands to the z/OS console by establishing an extended Multiple Console Support (MCS) console.
With the zos-console command group, you can perform the following tasks: Important! Before you issue z/OS console commands with Zowe CLI, security administrators should ensure that they provide access to commands that are appropriate for your organization.
- Issue commands to the z/OS console.
- Collect command responses and continue to collect solicited command responses on-demand.
Note: For more information about zos-console
syntax, actions, and options, open Zowe CLI and issue the following command:
zowe zos-console -h
#
zos-filesThe zos-files command group lets you interact with data sets on z/OS systems.
With the zos-files command group, you can perform the following tasks:
- Create partitioned data sets (PDS) with members, physical sequential data sets (PS), and other types of data sets from templates. You can specify options to customize the data sets you create.
- Download mainframe data sets and edit them locally in your preferred Integrated Development Environment (IDE).
- Upload local files to mainframe data sets.
- List available mainframe data sets.
- Interact with VSAM data sets directly, or invoke Access Methods Services (IDCAMS) to work with VSAM data sets.
Note: For more information about zos-files
syntax, actions, and options, open Zowe CLI and issue the following command:
zowe zos-files -h
#
zos-jobsThe zos-jobs command group lets you submit jobs and interact with jobs on z/OS systems.
With the zos-jobs command group, you can perform the following tasks:
- Submit jobs from JCL that resides on the mainframe or a local file.
- List jobs and spool files for a job.
- View the status of a job or view a spool file from a job.
Note: For more information about zos-jobs
syntax, actions, and options, open Zowe CLI and issue the following command:
zowe zos-jobs -h
#
zos-workflowsThe zos-workflows command group lets you create and manage z/OSMF workflows on a z/OS system.
With the zos-workflows command group, you can perform the following tasks:
- Create or register a z/OSMF workflow based on the properties on a z/OS system
- Start a z/OSMF workflow on a z/OS system.
- Delete or remove a z/OSMF workflow from a z/OS system.
- List the z/OSMF workflows for a system or sysplex.
Note: For more information about zos-workflows
syntax, actions, and options, open Zowe CLI and issue the following command:
zowe zos-workflows -h
#
zos-tsoThe zos-tso command group lets you issue TSO commands and interact with TSO address spaces on z/OS systems.
With the zos-tso command group, you can perform the following tasks:
- Excecute REXX scripts
- Create a TSO address space and issue TSO commands to the address space.
- Review TSO command response data in Zowe CLI.
Note: For more information about zos-tso
syntax, actions, and options, open Zowe CLI and issue the following
command:
zowe zos-tso -h
#
zosmfThe zosmf command group lets you work with Zowe CLI profiles and get general information about z/OSMF.
With the zosmf command group, you can perform the following tasks:
- Create and manage your Zowe CLI zosmf profiles. You must have at least one zosmf profile to issue most commands. Issue the
zowe help explain profiles
command in Zowe CLI to learn more about using profiles. - Verify that your profiles are set up correctly to communicate with z/OSMF on your system. For more information, see Test Connection to z/OSMF.
- Get information about the current z/OSMF version, host, port, and plug-ins installed on your system.
Note: For more information about zosmf
syntax, actions, and options, open Zowe CLI and issue the following command:
zowe zosmf -h
#
Writing scripts to automate mainframe actionsYou can combine multiple Zowe CLI commands in bash or shell scripts to automate actions on z/OS. You can implement scripts to enhance your development workflow, automate repetitive test or build tasks, and orchestrate mainframe actions from continuous integration/continuous deployment (CI/CD) tools such as Jenkins or TravisCI.
#
Writing a ScriptWrite a script that executes multiple CLI commands.
Note: The type of script that you write depends on the programming languages that you use and the environment where the script is executed. The following procedure is a general guide to Zowe CLI scripts, but you might need to refer to third-party documentation to learn more about scripting in general.
Follow these steps:
Create a new file on your computer with the extension .sh. For example,
testScript.sh
.Note: On Linux, an extension is not required. You make the file executable by issuing the command
chmod u+x testScript
.At the top of the file, specify the interpreter that your script requires. For example, type
#!/bin/sh
or#!/bin/sh
.Note: The command terminal that you use to execute the script depends on what you specify at the top of your script. Bash scripts require a bash interpreter (bash terminal), while shell scripts can be run from any terminal.
Write a script using a series of Zowe CLI commands.
Tip: You can incorporate commands from other command-line tools in the same script. You might choose to "pipe" the output of one command into another command.
From the appropriate command terminal, issue a command to execute the script. The command you use to execute script varies by operating system.
The script runs and prints the output in your terminal. You can run scripts manually, or include them in your automated testing and delivery pipelines.
Example: Clean up Temporary Data Sets#
The script in this example lists specified data sets, then loops through the list of data sets and deletes each file. You can use a similar script to clean up temporary data sets after use.
Note: This script must be run from a bash terminal.
#!/bin/bashset -e# Project cleanup script - deletes temporary project data sets# Obtain the list of temporary project data sets dslist=$(zowe files ls ds "my.project.ds*")# Delete each data set in the listIFS=$'\n'for ds in $dslistdo echo "Deleting Temporary Project Dataset: $ds" zowe files delete ds "$ds" -fdone
Example: Submit Jobs and Save Spool Output#
The script in this example submits a job, waits for the job to enter output status, and saves the spool files to local files on your computer.
Note: This script must be run from a bash terminal.
#! /bin/env bash#submit our jobjobid=$(zowe zos-jobs submit data-set "boech02.public.cntl(iefbr14)" --rff jobid --rft string)echo "Submitted our job, JOB ID is $jobid"#wait for job to go to outputstatus="UNKNOWN"while [[ "$status" != "OUTPUT"]]; do echo "Checking status of job $jobid" status=$(zowe zos-jobs view job-status-by-jobid "$jobid" --rff status --rft string) echo "Current status is $status" sleep 5sdone;echo "Job completed in OUTPUT status. Final result of job: "zowe zos-jobs view job-status-by-jobid "$jobid"# get a list of all of the spool files for our job now that it's in outputspool_ids=$(zowe zos-jobs list spool-files-by-jobid "$jobid" --rff id --rft table)# save each spool ID to a custom file namewhile read -r id; do zowe zos-jobs view spool-file-by-id "$jobid" "$id" > ./${jobid}_spool_${id}.txt echo "Saved spool DD to ./${jobid}_spool_${id}.txt"done <<< "$spool_ids"