mgo
OS/400 Edition
Volume 3, Number 6 -- January 29, 2003

Retrieve Qshell Exit Status in CL Programs


Hey, Ted:

In the article, "Using Grep to Search Source Physical Files", which published in the November 13, 2002, issue of Midrange Guru, you presented a way to extract Qshell's return code when running a Qshell utility in a CL program. I know a better way.

I've been using this routine to get the return code from the QSH command in CL.

DCL &MSGDTA    *CHAR   4 
DCL &MSGID     *CHAR   7 
DCL &RTNCODE   *DEC  (10 0) 

QSH CMD(whatever) 

RCVMSG     MSGTYPE(*LAST) RMV(*NO) MSGDTA(&MSGDTA)  + 
             MSGID(&MSGID) 
IF (&MSGID = 'QSH0005') CHGVAR &RTNCODE %BIN(&MSGDTA) 

Now &RTNCODE has the decimal value of the return code.

-- Ken


My thanks to Ken for this tip.

I did some digging and found that Qshell sends message QSH0005 after it executes a command. If you look at that message, which is in message file QSHELL/QZSHMSGF, you'll see that the return code is a four-byte integer value in the field data.

-- Ted


Sponsored By
WORKSRIGHT SOFTWARE

CASS Certification

What is it? Why do you need it?

CASS stands for "Coding Accuracy Support System." This test, developed by the U.S. Postal Service, determines whether ZIP Code software can accurately assign ZIP Codes to mailing addresses. WorksRight offers CASS-certified software intended to improve the accuracy of carrier route, 5-digit ZIP, ZIP+4, and delivery point codes.

For more information
or a 30-day free trial, visit

www.worksright.com
or call 601-856-8337.


THIS ISSUE
SPONSORED BY:

ASC
WorksRight Software


BACK ISSUES

TABLE OF
CONTENTS

Converting Alpha to Numeric

Retrieve Qshell Exit Status in CL Programs

Reader Feedback and Insights: Effective Communication



Editors
Howard Arner
Joe Hertvik
Ted Holt
David Morris

Managing Editor
Mari Barrett

Publisher and
Advertising Director:

Jenny Thomas

Advertising Sales Representative
Kim Reed

Contact the Editors
Do you have a gripe, inside dope or an opinion?
Email the editors:
editors@itjungle.com

Copyright © 1996-2008 Guild Companies, Inc. All Rights Reserved.