Problem solve Get help with specific problems with your technologies, process and projects.

Using System Request to execute a command

If your workstation is running some batch job and you don't have any other display session to execute command, you can use the "send a message option" from the system request menu to execute the command.

You Can View User Feedback To This Tip

If your workstation is running some batch job and you don't have any other display session to execute command, you can use the "send a message option" from the system request menu to execute the command.

That program allows you to send a message to a message queue by using the System Request key with option 5 (Send a message). That can be done even while your workstation is input-inhibited. By using that program, the "Send a message" option can be used to send a command that gets executed by the operating system. The following command must be executed before MYCMD can be used, ADDLIBLE LIB(qtemp) Crtmsgq msgq(qtemp/q) Chgmsgq msgq(qtemp/q) dlver(*break) pgm(mycmd)

CL program name MYCMD

PGM PARM(&QUE &LIB &KEY)
DCL VAR(&QUE) TYPE(*CHAR) LEN(10)
DCL VAR(&LIB) TYPE(*CHAR) LEN(10)
DCL VAR(&KEY) TYPE(*CHAR) LEN(4)
DCL VAR(&CMD) TYPE(*CHAR) LEN(132)

ENDPGM

The program MYCMD executes a command that is sent to it from a message queue. After creating the program, enter the commands ADDLIBLE LIB(qtemp), Crtmsgq msgq(qtemp/q), Chgmsgq msgq(qtemp/q) dlver(*break) pgm(mycmd) or add them to your initial program.

To enter a command at any time, press the System Request key and enter a "5" followed by a command in single quotes and the parameter TOMSGQ(Q).

For example:

5 ' WRKJOB OUTPUT(*PRINT)' tomsgq(q) If you want to prompt the command, put a question mark in front of the command (i.e. ? WRKJOB OUTPUT(*PRINT).

USER FEEDBACK TO THIS TIP

  • There are easier ways to enable this than using a message queue break handling program...

    For example, Command SYSRQ90:

    WHEN A USER ENTERS "SYSRQ 90" THIS COMMAND IS CALLED. IF THEY ARE AUTHORIZED TO *AUTL SYSRQ90, THY WILL GET A COMMAND LINE OTHERWISE THEY WILL BE SIGNED OFF. MESSAGE DESCRIPTION CPX2313 WAS UPDATED TO CALL THIS PROGRAM INSTEAD OF "SIGNOFF"

     
     PGM
     DCL        VAR(&USER) TYPE(*CHAR) LEN(10) 
     DCL        VAR(&GROUP) TYPE(*CHAR) LEN(10)
     DCL        VAR(&READ) TYPE(*CHAR) LEN(10) 
     DCL        &ERRORSW *LGL                  
     DCL        &MSGID *CHAR LEN(7)            
     DCL        &MSGDTA *CHAR LEN(100)         
     DCL        &MSGF *CHAR LEN(10)            
     DCL        &MSGFLIB *CHAR LEN(10)
     MONMSG     MSGID(CPF0000) EXEC(GOTO CMDLBL(STDERR1)) 
                RTVUSRPRF  RTNUSRPRF(&USER) GRPPRF(&GROUP)                   
                                                                             
    USER:       RTVAUTLE   AUTL(SYSRQ90) USER(&USER) READ(&READ)             
                MONMSG     MSGID(CPF22A7 CPF22A8) EXEC(GOTO CMDLBL(GROUP))   
                                                                             
                   IF         COND(&READ *EQ *READ) THEN(DO)                 
                    CALL       PGM(QSYS/QUSCMDLN)                            
                    GOTO       CMDLBL(END)                                   
                   ENDDO                                                     
                                                                             
                GOTO       CMDLBL(SIGNOFF)                                   
                                                                             
    GROUP:      IF         COND(&GROUP *EQ *NONE) THEN(GOTO +                
                             CMDLBL(SIGNOFF))                                
                RTVAUTLE   AUTL(SYSRQ90) USER(&GROUP) READ(&READ)            
                MONMSG     MSGID(CPF22A7 CPF22A8) EXEC(GOTO +                
                             CMDLBL(SIGNOFF))                                
                                                                             
                   IF         COND(&READ *EQ *READ) THEN(DO)                 
                    CALL       PGM(QSYS/QUSCMDLN)                            
                    GOTO       CMDLBL(END)                                  
                   ENDDO                                                    
                                                                            
    SIGNOFF:   SIGNOFF    LOG(*LIST)
    END:        RETURN
    STDERR1:               /* Standard error handling routine */            
                IF         &ERRORSW SNDPGMMSG MSGID(CPF9999) +              
                             MSGF(QCPFMSG) MSGTYPE(*ESCAPE) /* Func chk */  
                CHGVAR     &ERRORSW '1' /* Set to fail ir error occurs */   
    STDERR2:    RCVMSG     MSGTYPE(*DIAG) MSGDTA(&MSGDTA) MSGID(&MSGID) +   
                             MSGF(&MSGF) MSGFLIB(&MSGFLIB)                  
                IF         (&MSGID *EQ '       ') GOTO STDERR3              
                SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +             
                             MSGDTA(&MSGDTA) MSGTYPE(*DIAG)                 
                GOTO       STDERR2 /* Loop back for addl diagnostics */     
    STDERR3:    RCVMSG     MSGTYPE(*EXCP) MSGDTA(&MSGDTA) MSGID(&MSGID) +   
                             MSGF(&MSGF) MSGFLIB(&MSGFLIB)                  
                SNDPGMMSG  MSGID(&MSGID) MSGF(&MSGFLIB/&MSGF) +             
                             MSGDTA(&MSGDTA) MSGTYPE(*ESCAPE)               
                ENDPGM   
    —Ken Graap, Search400.com expert


This was last published in March 2006

Dig Deeper on iSeries programming commands

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.

-ADS BY GOOGLE

SearchDataCenter

Close