-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathjobs.py
67 lines (51 loc) · 1.99 KB
/
jobs.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
from zoautil_py import jobs, datasets
jcl_sample = """//UPTIME JOB MSGLEVEL=(1,1),
// MSGCLASS=A,CLASS=A
//******************************************************************************
//* Configure the job card as needed, most common keyword parameters often
//* needing editing are:
//* CLASS: Used to achieve a balance between different types of jobs and avoid
//* contention between jobs that use the same resources.
//* MSGLEVEL: controls hpw the allocation messages and termination messages are
//* printed in the job's output listing (SYSOUT).
//* MSGCLASS: assign an output class for your output listing (SYSOUT)
//******************************************************************************
//*
//* PRINT USS COMMAND ON JOB OUTPUT
//*
//UPTIME EXEC PGM=BPXBATCH,REGION=0M
//STDPARM DD *
SH uptime
//STDIN DD DUMMY
//STDOUT DD SYSOUT=*
//STDERR DD SYSOUT=*
//"""
def run_sample():
dsn_sample_jcl = datasets.hlq() + ".SAMPLE.JCL"
dsn_with_mem_sample_jcl = dsn_sample_jcl + "(UPTIME)"
# NOTE - data set does NOT need to exist prior to running this sample.
# create and write JCL to data set
datasets.write(dataset=dsn_with_mem_sample_jcl, content=jcl_sample)
# submit job
job_sample = jobs.submit(dsn_with_mem_sample_jcl)
print("Details - sample job")
print("id:", job_sample.id)
print("name:", job_sample.name)
print("owner:", job_sample.owner)
print("status:", job_sample.status)
print("rc:", job_sample.rc)
print("Waiting for job completion, then refresh and print status, rc...")
job_sample.wait()
job_sample.refresh()
print("status: ", job_sample.status)
print("rc: ", job_sample.rc)
dd_stdout = jobs.read_output(job_sample.id, 'UPTIME', 'STDOUT')
# print the stdout produced by job
print("The contents of the STDOUT DD:")
print(dd_stdout)
# cleanup:
# cancels and removes job from jes system
job_sample.purge()
# delete data set
datasets.delete(dsn_sample_jcl)
run_sample()