Skip to content

Instantly share code, notes, and snippets.

@plavjanik
Created March 22, 2022 11:25
Show Gist options
  • Select an option

  • Save plavjanik/3ec51850ce757d80b62b7eac336ba88f to your computer and use it in GitHub Desktop.

Select an option

Save plavjanik/3ec51850ce757d80b62b7eac336ba88f to your computer and use it in GitHub Desktop.
Calling Zowe CLI command and parsing JSON output
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