Created
March 22, 2022 11:25
-
-
Save plavjanik/3ec51850ce757d80b62b7eac336ba88f to your computer and use it in GitHub Desktop.
Calling Zowe CLI command and parsing JSON output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import subprocess | |
| import json | |
| completed_process = subprocess.run('zowe zos-jobs list jobs --rfj', | |
| shell=True, capture_output=True, check=True, encoding="utf8") | |
| jobs = json.loads(completed_process.stdout)["data"] | |
| for job in jobs: | |
| if job['status'] == 'OUTPUT': | |
| print(f"Job {job['jobname']}({job['jobid']}) has return code {job['retcode']}") | |
| # Sample output: | |
| # Job ZOWEUSER(TSU08423) has return code ABEND S222 | |
| # Job ZOWEUSERA(JOB10931) has return code CC 0000 | |
| # Job ZOWEUSERA(JOB10930) has return code CC 0000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment