Skip to content

Commit e3c8889

Browse files
Created QSHONISRV service program
1 parent e7ccafc commit e3c8889

7 files changed

+579
-15
lines changed

QSHONIPR01.RPGLE

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
**FREE
2+
3+
Ctl-Opt DFTACTGRP(*NO) BNDDIR('QSHONI/QSHONISRV') OPTION(*SRCSTMT);
4+
5+
Dcl-F STDOUTQSH DISK(1000) Usage(*Input) usropn;
6+
7+
//TODO:
8+
// Retrieve error message and CPF ID on failure if needed.
9+
10+
Dcl-Ds *N psds;
11+
PROGID *PROC;
12+
End-Ds;
13+
14+
Dcl-Ds qshlog;
15+
logrecord char(1000);
16+
End-Ds;
17+
18+
// Work fields
19+
Dcl-S qt Char(1) inz('''');
20+
Dcl-S clcmd VarChar(5000) inz('');
21+
dcl-s rtncmd int(10);
22+
23+
// Include QSHONISRV service program prototypes
24+
/copy qshoni/source,qshonisrvh
25+
26+
// Sample CL command call. 0=Success, -2=Errors
27+
// Uncomment if you want to test calling a CL command.
28+
// rtncmd=RunClCmd('SNDMSG MSG(TEST) TOUSR(QSYSOPR);
29+
30+
// Sample QSHEXEC QShell/PASE command call. 0=Success, -2=Errors
31+
// Prompt for the CL command and display STDOUT after run.
32+
// Lists files in /tmp directory.
33+
rtncmd=QshExec('cd /tmp;ls -l': // QSH/PASE command line
34+
'*YES': // SETPKGPATH
35+
'*YES': // DSPSTDOUT
36+
'*NO': // LOGSTDOUT
37+
'*NO': // PRTSTDOUT
38+
'*YES': // DLTSTDOUT
39+
'*NO': // IFSSTDOUT
40+
'': // IFSFILE
41+
'*REPLACE': // IFSOPT
42+
'*SAME': // CCSID
43+
'QSHONIPR1': // PRTSPLF
44+
'': // PRTUSRDTA
45+
'': // PRTTXT
46+
'*NO': // PRTHOLD
47+
'*SAME': // PRTOUTQ
48+
'QTEMP/STDOUTQSH': // OUTFILE
49+
'*REPLACE': // MBROPT
50+
'*DEFAULT': // PASEJOBNAM
51+
'*YES');// Prompt Command (Interactive debug or use)
52+
53+
// Note: This section reads the STDOUT log file.
54+
// Make sure to only create STDOUTQSH in QTEMP library
55+
// so the job only gets its own STDOUTQSH file.
56+
57+
// Open log file and set to beginning of
58+
open STDOUTQSH;
59+
setll *start STDOUTQSH;
60+
61+
// Read all records in QTEMP/STDOUTQSH file
62+
dou %eof(STDOUTQSH);
63+
64+
// Read next record from STDOUTQSH
65+
read STDOUTQSH qshlog;
66+
67+
// Process and scan or extract info from record1 field as needed
68+
69+
// If end of file, exit process loop
70+
if %eof(STDOUTQSH);
71+
leave;
72+
endif;
73+
74+
enddo;
75+
76+
77+
// Exit the program now. We're done
78+
close STDOUTQSH;
79+
*inlr=*on;
80+
return;
81+

QSHONIPR02.RPGLE

+81
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
**FREE
2+
3+
Ctl-Opt DFTACTGRP(*NO) BNDDIR('QSHONI/QSHONISRV') OPTION(*SRCSTMT);
4+
5+
Dcl-F STDOUTQSH DISK(1000) Usage(*Input) usropn;
6+
7+
//TODO:
8+
// Retrieve error message and CPF ID on failure if needed.
9+
10+
Dcl-Ds *N psds;
11+
PROGID *PROC;
12+
End-Ds;
13+
14+
Dcl-Ds qshlog;
15+
logrecord char(1000);
16+
End-Ds;
17+
18+
// Work fields
19+
Dcl-S qt Char(1) inz('''');
20+
Dcl-S clcmd VarChar(5000) inz('');
21+
dcl-s rtncmd int(10);
22+
23+
// Include QSHONISRV service program prototypes
24+
/copy qshoni/source,qshonisrvh
25+
26+
// Sample CL command call. 0=Success, -2=Errors
27+
// Uncomment if you want to test calling a CL command.
28+
// rtncmd=RunClCmd('SNDMSG MSG(TEST) TOUSR(QSYSOPR);
29+
30+
// Sample QSHBASH QShell/PASE command call. 0=Success, -2=Errors
31+
// Prompt for the CL command and display STDOUT after run.
32+
// Lists files in /tmp directory.
33+
rtncmd=QshBash('cd /tmp;ls -l': // QSH/PASE command line
34+
'*YES': // SETPKGPATH
35+
'*YES': // DSPSTDOUT
36+
'*NO': // LOGSTDOUT
37+
'*NO': // PRTSTDOUT
38+
'*YES': // DLTSTDOUT
39+
'*NO': // IFSSTDOUT
40+
'': // IFSFILE
41+
'*REPLACE': // IFSOPT
42+
'*SAME': // CCSID
43+
'QSHONIPR1': // PRTSPLF
44+
'': // PRTUSRDTA
45+
'': // PRTTXT
46+
'*NO': // PRTHOLD
47+
'*SAME': // PRTOUTQ
48+
'QTEMP/STDOUTQSH': // OUTFILE
49+
'*REPLACE': // MBROPT
50+
'*DEFAULT': // PASEJOBNAM
51+
'*YES');// Prompt Command (Interactive debug or use)
52+
53+
// Note: This section reads the STDOUT log file.
54+
// Make sure to only create STDOUTQSH in QTEMP library
55+
// so the job only gets its own STDOUTQSH file.
56+
57+
// Open log file and set to beginning of
58+
open STDOUTQSH;
59+
setll *start STDOUTQSH;
60+
61+
// Read all records in QTEMP/STDOUTQSH file
62+
dou %eof(STDOUTQSH);
63+
64+
// Read next record from STDOUTQSH
65+
read STDOUTQSH qshlog;
66+
67+
// Process and scan or extract info from record1 field as needed
68+
69+
// If end of file, exit process loop
70+
if %eof(STDOUTQSH);
71+
leave;
72+
endif;
73+
74+
enddo;
75+
76+
77+
// Exit the program now. We're done
78+
close STDOUTQSH;
79+
*inlr=*on;
80+
return;
81+

0 commit comments

Comments
 (0)