Example: Creating and running the server program

Creating the server program The following example shows how to create the server program on i5/OS(TM). The example assumes that the source for the server program is in member SERVER in the file QGPL/QCSRC. The server program is owned by a special user profile QSHSVR that has minimal authorities but private authority to the QSYGETPH(), QSYRLSPH(), and QWTSETP() APIs. It is not possible to sign on using the QSHSVR user profile. The server program adopts the authority of QSHSVR so it can switch to the client's user profile.
CRTBNDC   PGM(QGPL/SERVER) 
          SRCFILE(QGPL/QCSRC) 
          SRCMBR(SERVER) 
          OPTIMIZE(40)
          SYSIFCOPT(*IFSIO)
          LOCALETYPE(*LOCALE)
          USRPRF(*OWNER)
          AUT(*USE)
          TEXT('Shell server')
CRTUSRPRF USRPRF(QSHSVR) 
          PASSWORD(*NONE) 
          USRCLS(*USER) 
          TEXT('Shell server profile')
CHGOBJOWN OBJ(QGPL/SERVER)
          OBJTYPE(*PGM)
          NEWOWN(QSHSVR)
GRTOBJAUT OBJ(QSYS/QSYGETPH) 
          OBJTYPE(*PGM) 
          USER(QSHSVR) 
          AUT(*USE)
GRTOBJAUT OBJ(QSYS/QSYRLSPH) 
          OBJTYPE(*PGM) 
          USER(QSHSVR) 
          AUT(*USE)
GRTOBJAUT OBJ(QSYS/QWTSETP) 
          OBJTYPE(*PGM) 
          USER(QSHSVR) 
          AUT(*USE)
Running the server program You may want to run the server program and any child processes started by the server in their own subsystem. The following example shows how to create the following objects:
CRTSBSD   SBSD(QGPL/SHELL)
          POOLS((1 *BASE))
          AUT(*USE)
          TEXT('Shell server subsystem')
CRTCLS    CLS(QGPL/SHELL)
          RUNPTY(20)
          TIMESLICE(2000)
          DFTWAIT(30)
          AUT(*USE)
          TEXT('Shell server class')
CRTJOBQ   JOBQ(QGPL/SHELL) 
          AUTCHK(*DTAAUT)
          AUT(*USE)
          TEXT('Shell server job queue')
CRTJOBD   JOBD(QGPL/SHELL)  
          JOBQ(QGPL/SHELL)
          AUT(*USE)
          TEXT('Shell server job description')
ADDJOBQE  SBSD(QGPL/SHELL)
          JOBQ(QGPL/SHELL)
          MAXACT(*NOMAX)
ADDRTGE   SBSD(QGPL/SHELL) 
          SEQNBR(1) 
          CMPVAL(*ANY) 
          PGM(*LIBL/QCMD)
ADDPJE    SBSD(QGPL/SHELL)
          PGM(QSYS/QP0ZSPWP)
          USER(QSHSVR)
          STRJOBS(*YES)
          INLJOBS(10)
          THRESHOLD(2)
          ADLJOBS(3)
          MAXJOBS(*NOMAX)
          JOBD(QGPL/SHELL)
ADDPJE    SBSD(QGPL/SHELL)
          PGM(QSYS/QP0ZSPWT)
          USER(QSHSVR)
          STRJOBS(*YES)
          INLJOBS(10)
          THRESHOLD(2)
          ADLJOBS(3)
          MAXJOBS(*NOMAX)
          JOBD(QSYS/QAMTJOBD)
Starting the subsystem The following example shows how to start the subsystem described in the previous example and the server program.
STRSBS    SBSD(QGPL/QSHELL)
SBMJOB    CMD(CALL QGPL/SERVER) 
          JOB(SERVER) 
          JOBD(QGPL/SHELL) 
          JOBQ(QGPL/SHELL)
          USER(QSHSVR)