Tip

Start QCMD anytime-- even if the terminal is Input Inhibited

Years ago, I got very annoyed not being able to 'break in' the middle of a long-running jobstream and start the debugger. If I could only get to a command line when the terminal was input inhibited!

The only way I could think of interrupting a job was simply by using the System Request key. After looking at the System Request Menu -- and realizing you could send messages to specific message queues from a System Request command line and you could evoke a program whenever a message queue received a message -- I determined it was possible to create a "programmus interruptus" utility that would give me a command line or let me execute debug commands directly.

The result was two CL programs, DOINK and DOINKSTER, and a command handler, also called DOINK. (For lack of a better name.)

The way it works is like this:

  1. When you create the programs and the command handler, make sure they're all created in the same library and that library is present in your library list.
  2. At sign-on time, set up your DOINK by typing DOINK at the command line.
  3. To evoke DOINK, do the following:
    -Bring up the System request command
    line.
    -Enter the following "5 q q" (the
    number 5, followed by a space, the
    letter q, another space, and another
    q).
    -Press Enter
    -The QCMD command entry screen
    appears.
  4. You can also run OS/400 commands by entering "5 '' q. For example, to run an EDTLIBL command, you'd simply type in "5 EDTLIBL q", and the EDTLIBL command runs, and you'll see the library list. Remember, if you do specify a different command, you'll be subject to all the AS/400 quoting rules that you'd find when having to assemble a CL command that would be executed by QCMDEXC.

    How it works

    When the DOINK command is executed, the DOINK cpp sets up a special message queue called, simply, Q in the QTEMP library. Then the message queue is changed to call a program when the queue receives a message. The program called is DOINKSTER.

    When Q receives a message, it calls DOINKSTER. OS/400 is kind enough to pass the message queue, message queue library, and message key to DOINKSTER. DOINKSTER then pulls the message off the queue. If the message text is simply "q", then QCMD is called. If the message text is something else, then the message text is passed to QCMDEXC, and OS/400 will attempt to execute the message text.


    ================================== 
    DOINK Command Source 
    ---------------------------------- 
    DOINK:      CMD PROMPT('Install ALT-SYSRQS interrupt') 
    ================================== 
    DOINK Command Processing Program 
    ---------------------------------- 
    PGM 
    
    CRTMSGQ MSGQ(QTEMP/Q) 
    CHGMSGQ MSGQ(QTEMP/Q) DLVRY(*BREAK) + 
       PGM(*LIBL/DOINKSTER) 
    SNDPGMMSG MSG('DOINK installed') + 
       TOPGMQ(*PRV) 
    
    ENDIT: 
    ENDPGM 
    ================================== 
    DOINKSTER System Request Handler 
    ---------------------------------- 
    /* HANDLE DOINK REQUESTS */ 
    
    PGM PARM(&MSGQ &MSGQLIB &MSGKEY) 
    
    DCL  VAR(&MSGQ)    TYPE(*CHAR)   LEN(10) 
    DCL  VAR(&MSGQLIB) TYPE(*CHAR)   LEN(10) 
    DCL  VAR(&MSGKEY)  TYPE(*CHAR)   LEN(4) 
    DCL  VAR(&MSG)     TYPE(*CHAR)   LEN(80) 
    DCL  VAR(&LEN)     TYPE(*DEC)    + 
       LEN(15 5)   VALUE(80) 
    
    MONMSG MSGID(CPF0000) 
    RCVMSG MSGQ(&MSGQLIB/&MSGQ) + 
       MSGKEY (&MSGKEY) MSG(&MSG) 
    
    IF COND(&MSG *EQ 'Q') THEN(DO) 
       CALL PGM(QCMD) 
    ENDDO 
    ELSE CMD(DO) 
       CALL PGM(QCMDEXC) PARM(&LEN &MSG) 
    ENDDO 
    
    ENDIT: 
    ENDPGM 

    This was first published in February 2001

There are Comments. Add yours.

 
TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.