-
Notifications
You must be signed in to change notification settings - Fork 20
/
QSHPHPRUNC.CLLE
347 lines (323 loc) · 18.1 KB
/
QSHPHPRUNC.CLLE
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
PGM PARM(&PHPSCRDIR &SCRIPTFILE &ARGS &PHPPATH +
&SETPKGPATH &DSPSTDOUT &LOGSTDOUT +
&PRTSTDOUT &DLTSTDOUT &IFSSTDOUT &IFSFILE +
&IFSOPT &CCSID &PRTSPLF &PRTUSRDTA +
&PRTTXT &PRTHOLD &PRTOUTQALL &OUTFILE +
&MBROPT &PASEJOBNAM &DEBUGCMD &CHGSCRDIR)
DCL VAR(&OFILE) TYPE(*CHAR) LEN(10)
DCL VAR(&OLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&DEBUGCMD) TYPE(*CHAR) LEN(4)
DCL VAR(&MBROPT) TYPE(*CHAR) LEN(10)
DCL VAR(&OUTFILE) TYPE(*CHAR) LEN(20)
DCL VAR(&PRTHOLD) TYPE(*CHAR) LEN(4)
DCL VAR(&PRTOUTQALL) TYPE(*CHAR) LEN(20)
DCL VAR(&PRTOUTQ) TYPE(*CHAR) LEN(10)
DCL VAR(&PRTOUTQLIB) TYPE(*CHAR) LEN(10)
DCL VAR(&PASEJOBNAM) TYPE(*CHAR) LEN(10)
DCL VAR(&CHGSCRDIR) TYPE(*CHAR) LEN(4)
DCL VAR(&CHGDIRCMD) TYPE(*CHAR) LEN(255)
DCL VAR(&SETPKGPATH) TYPE(*CHAR) LEN(4)
DCL VAR(&CCSID) TYPE(*CHAR) LEN(10)
DCL VAR(&PHPSCRDIR) TYPE(*CHAR) LEN(255)
DCL VAR(&PHPPATH) TYPE(*CHAR) LEN(255)
DCL VAR(&PHPEXE) TYPE(*CHAR) LEN(100)
DCL VAR(&SCRIPTFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&SCRIPTSTR) TYPE(*CHAR) LEN(1)
DCL VAR(&ARGS) TYPE(*CHAR) LEN(8002)
DCL VAR(&ARGS2) TYPE(*CHAR) LEN(8000)
DCL VAR(&CT) TYPE(*DEC) STG(*AUTO) LEN(3 0)
DCL VAR(&PRTTEXT) TYPE(*CHAR) LEN(30) +
VALUE('PHP Script Stdout')
DCL VAR(&APPDIR) TYPE(*CHAR) LEN(255)
DCL VAR(&CMD) TYPE(*CHAR) LEN(5000)
DCL VAR(&STDOUTFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&STDOUTIFS) TYPE(*CHAR) LEN(255)
DCL VAR(&QDATE) TYPE(*CHAR) LEN(6)
DCL VAR(&QTIME) TYPE(*CHAR) LEN(9)
DCL VAR(&JOB) TYPE(*CHAR) LEN(10)
DCL VAR(&USER) TYPE(*CHAR) LEN(10)
DCL VAR(&JOBNBR) TYPE(*CHAR) LEN(6)
DCL VAR(&TEMPDIR) TYPE(*CHAR) LEN(255) +
VALUE('/tmp')
DCL VAR(&PHPTEMP) TYPE(*CHAR) LEN(255) +
VALUE('/tmp/qsh')
DCL VAR(&QSHRTN) TYPE(*DEC) LEN(5 0)
DCL VAR(&QSHRTNC) TYPE(*CHAR) LEN(5)
DCL VAR(&MSGDTA) TYPE(*CHAR) LEN(200)
DCL VAR(&MSGDTA4) TYPE(*CHAR) LEN(4)
DCL VAR(&CPFID) TYPE(*CHAR) LEN(7)
DCL VAR(&DSPSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&DLTSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&LOGSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&PRTSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&PRTSPLF) TYPE(*CHAR) LEN(10)
DCL VAR(&PRTUSRDTA) TYPE(*CHAR) LEN(10)
DCL VAR(&PRTTXT) TYPE(*CHAR) LEN(30)
DCL VAR(&IFSSTDOUT) TYPE(*CHAR) LEN(4)
DCL VAR(&IFSOPT) TYPE(*CHAR) LEN(10)
DCL VAR(&IFSFILE) TYPE(*CHAR) LEN(255)
DCL VAR(&PHPPATHSEP) TYPE(*CHAR) LEN(1) VALUE(' ')
MONMSG MSGID(CPF0000) EXEC(GOTO CMDLBL(ERRORS))
/*----------------------------------------------------------------------------*/
/* Extract output queue info. */
/*----------------------------------------------------------------------------*/
CHGVAR VAR(&PRTOUTQ) VALUE(%SST(&PRTOUTQALL 1 10))
CHGVAR VAR(&PRTOUTQLIB) VALUE(%SST(&PRTOUTQALL 11 10))
/*----------------------------------------------------------------------------*/
/* Extract output file info. Added V1.0.16 */
/*----------------------------------------------------------------------------*/
CHGVAR VAR(&OFILE) VALUE(%SST(&OUTFILE 1 10))
CHGVAR VAR(&OLIB) VALUE(%SST(&OUTFILE 11 10))
/*----------------------------------------------------------------------------*/
/* If default PHP path data area, retreive from data area */
/*----------------------------------------------------------------------------*/
IF COND(&PHPPATH *EQ *DEFAULT) THEN(DO)
RTVDTAARA DTAARA(QSHONI/PHPPATH *ALL) RTNVAR(&PHPPATH)
/* No specific PHP path iif *DEFAULT and no PHPPATH data area found */
MONMSG MSGID(CPF0000) EXEC(DO)
CHGVAR VAR(&PHPPATH) VALUE(' ')
ENDDO
ENDDO
/*----------------------------------------------------------------------------*/
/* If PHPPATH <> '', add path separator because we will prefix PHP command */
/* Otherwise we don't need a path separator because we will call PHP */
/* without a path qualifier. */
/*----------------------------------------------------------------------------*/
IF COND(&PHPPATH *NE ' ') THEN(DO)
CHGVAR VAR(&PHPPATHSEP) VALUE('/')
ENDDO
/*----------------------------------------------------------------------------*/
/* Parse command line parms - up to 40 cmd line args */
/*----------------------------------------------------------------------------*/
CHGVAR VAR(&CT) VALUE(%BINARY(&ARGS 1 2))
IF COND(&CT > 0) THEN(CHGVAR VAR(&ARGS2) +
VALUE('"' |< %SST(&ARGS 3 200) |< '"'))
IF COND(&CT > 1) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 203 +
200) |< '"'))
IF COND(&CT > 2) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 403 +
200) |< '"'))
IF COND(&CT > 3) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 603 +
200) |< '"'))
IF COND(&CT > 4) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 803 +
200) |< '"'))
IF COND(&CT > 5) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 1003 +
200) |< '"'))
IF COND(&CT > 6) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 1203 +
200) |< '"'))
IF COND(&CT > 7) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 1403 +
200) |< '"'))
IF COND(&CT > 8) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 1603 +
200) |< '"'))
IF COND(&CT > 9) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 1803 +
200) |< '"'))
IF COND(&CT > 10) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 2003 +
200) |< '"'))
IF COND(&CT > 11) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 2203 +
200) |< '"'))
IF COND(&CT > 12) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 2403 +
200) |< '"'))
IF COND(&CT > 13) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 2603 +
200) |< '"'))
IF COND(&CT > 14) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 2803 +
200) |< '"'))
IF COND(&CT > 15) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 3003 +
200) |< '"'))
IF COND(&CT > 16) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 3203 +
200) |< '"'))
IF COND(&CT > 17) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 3403 +
200) |< '"'))
IF COND(&CT > 18) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 3603 +
200) |< '"'))
IF COND(&CT > 19) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 3803 +
200) |< '"'))
IF COND(&CT > 20) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 4003 +
200) |< '"'))
IF COND(&CT > 21) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 4203 +
200) |< '"'))
IF COND(&CT > 22) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 4403 +
200) |< '"'))
IF COND(&CT > 23) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 4603 +
200) |< '"'))
IF COND(&CT > 24) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 4803 +
200) |< '"'))
IF COND(&CT > 25) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 5003 +
200) |< '"'))
IF COND(&CT > 26) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 5203 +
200) |< '"'))
IF COND(&CT > 27) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 5403 +
200) |< '"'))
IF COND(&CT > 28) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 5603 +
200) |< '"'))
IF COND(&CT > 29) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 5803 +
200) |< '"'))
IF COND(&CT > 30) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 6003 +
200) |< '"'))
IF COND(&CT > 31) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 6203 +
200) |< '"'))
IF COND(&CT > 32) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 6403 +
200) |< '"'))
IF COND(&CT > 33) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 6603 +
200) |< '"'))
IF COND(&CT > 34) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 6803 +
200) |< '"'))
IF COND(&CT > 35) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 7003 +
200) |< '"'))
IF COND(&CT > 36) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 7203 +
200) |< '"'))
IF COND(&CT > 37) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 7403 +
200) |< '"'))
IF COND(&CT > 38) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 7603 +
200) |< '"'))
IF COND(&CT > 39) THEN(CHGVAR VAR(&ARGS2) +
VALUE(&ARGS2 |> '"' |< %SST(&ARGS 7803 +
200) |< '"'))
/*----------------------------------------------------------------------------*/
/* Set PHP executable */
/*----------------------------------------------------------------------------*/
CHGVAR VAR(&PHPEXE) VALUE(&PHPPATH |< &PHPPATHSEP |< 'php')
/*----------------------------------------------------------------------------*/
/* Make sure QSHONITMP library and IFS directory created */
/*----------------------------------------------------------------------------*/
CHKOBJ OBJ(QSHONITMP) OBJTYPE(*LIB)
MONMSG MSGID(CPF9801) EXEC(DO)
CRTLIB LIB(QSHONITMP) TEXT('Qshoni Temp File +
Library') AUT(*ALL)
ENDDO
/*----------------------------------------------------------------------------*/
/* Make sure /tmp folder exists */
/*----------------------------------------------------------------------------*/
QSHIFSCHK FILNAM(&TEMPDIR)
/* EXISTS, DO NOTHING SPECIAL */
MONMSG MSGID(CPF9897) EXEC(DO)
ENDDO
/* DOES NOT EXIST. BAIL OUT */
MONMSG MSGID(CPF9898) EXEC(DO)
MKDIR DIR(&TEMPDIR) DTAAUT(*RWX) OBJAUT(*ALL)
ENDDO
/*----------------------------------------------------------------------------*/
/* Make sure /tmp/qsh exist for logs */
/*----------------------------------------------------------------------------*/
QSHIFSCHK FILNAM(&PHPTEMP)
/* EXISTS, DO NOTHING SPECIAL */
MONMSG MSGID(CPF9897) EXEC(DO)
ENDDO
/* DOES NOT EXIST. BAIL OUT */
MONMSG MSGID(CPF9898) EXEC(DO)
MKDIR DIR(&PHPTEMP) DTAAUT(*RWX) OBJAUT(*ALL)
ENDDO
/*----------------------------------------------------------------------------*/
/* Retreive system values for job */
/*----------------------------------------------------------------------------*/
RTVSYSVAL SYSVAL(QDATE) RTNVAR(&QDATE)
RTVSYSVAL SYSVAL(QTIME) RTNVAR(&QTIME)
RTVJOBA JOB(&JOB) USER(&USER) NBR(&JOBNBR)
/* Get first char of script file to check for / */
/* If path starts with slash do not use dtaara */
CHGVAR VAR(&SCRIPTSTR) VALUE(%SST(&SCRIPTFILE 1 1))
/* If cur php dir set and script file has no slash / */
/* concatenate php dir with script file name */
IF COND(&PHPSCRDIR *NE ' ' *AND &SCRIPTSTR *NE +
'/') THEN(DO)
CHGVAR VAR(&SCRIPTFILE) VALUE(&PHPSCRDIR |< '/' +
|< &SCRIPTFILE)
ENDDO
/*----------------------------------------------------------------------------*/
/* Make sure PHP script exists */
/*----------------------------------------------------------------------------*/
QSHIFSCHK FILNAM(&SCRIPTFILE)
/* EXISTS, DO NOTHING SPECIAL */
MONMSG MSGID(CPF9897) EXEC(DO)
ENDDO
/* DOES NOT EXIST. BAIL OUT */
MONMSG MSGID(CPF9898) EXEC(DO)
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('PHP +
script file' |> &SCRIPTFILE |> 'does not +
exist') MSGTYPE(*ESCAPE)
ENDDO
/*----------------------------------------------------------------------------*/
/* Build PHP command call */
/*----------------------------------------------------------------------------*/
CHGVAR VAR(&CMD) VALUE(&PHPEXE |> &SCRIPTFILE |> +
&ARGS2)
/*----------------------------------------------------------------------------*/
/* Call QSHEXEC command to run PHP script via Qshell */
/*----------------------------------------------------------------------------*/
IF COND(&DEBUGCMD *EQ *YES) THEN(DO)
? QSHONI/QSHEXEC CMDLINE(&CMD) SETPKGPATH(&SETPKGPATH) +
DSPSTDOUT(&DSPSTDOUT) +
LOGSTDOUT(&LOGSTDOUT) +
PRTSTDOUT(&PRTSTDOUT) +
DLTSTDOUT(&DLTSTDOUT) +
IFSSTDOUT(&IFSSTDOUT) IFSFILE(&IFSFILE) +
IFSOPT(&IFSOPT) CCSID(&CCSID) +
PRTSPLF(&PRTSPLF) PRTUSRDTA(&PRTUSRDTA) +
PRTTXT(&PRTTXT) PRTHOLD(&PRTHOLD) +
PRTOUTQ(&PRTOUTQLIB/&PRTOUTQ) +
OUTFILE(&OLIB/&OFILE) MBROPT(&MBROPT) +
PASEJOBNAM(&PASEJOBNAM)
ENDDO
IF COND(&DEBUGCMD *NE *YES) THEN(DO)
QSHONI/QSHEXEC CMDLINE(&CMD) SETPKGPATH(&SETPKGPATH) +
DSPSTDOUT(&DSPSTDOUT) +
LOGSTDOUT(&LOGSTDOUT) +
PRTSTDOUT(&PRTSTDOUT) +
DLTSTDOUT(&DLTSTDOUT) +
IFSSTDOUT(&IFSSTDOUT) IFSFILE(&IFSFILE) +
IFSOPT(&IFSOPT) CCSID(&CCSID) +
PRTSPLF(&PRTSPLF) PRTUSRDTA(&PRTUSRDTA) +
PRTTXT(&PRTTXT) PRTHOLD(&PRTHOLD) +
PRTOUTQ(&PRTOUTQLIB/&PRTOUTQ) +
OUTFILE(&OLIB/&OFILE) MBROPT(&MBROPT) +
PASEJOBNAM(&PASEJOBNAM)
ENDDO
NORMAL:
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('PHP +
script' |> &SCRIPTFILE |> 'completed +
successfully with no errors') MSGTYPE(*COMP)
RETURN
/*----------------------------------------------------------------------------*/
/* Handle Errors */
/*----------------------------------------------------------------------------*/
ERRORS:
SNDPGMMSG MSGID(CPF9898) MSGF(QCPFMSG) MSGDTA('PHP +
script' |> &SCRIPTFILE |> 'failed. See +
the joblog or stdout log') MSGTYPE(*ESCAPE)
ENDPGM