Re: Shelling out CRTLF via QCMDEXC -- question about success/failure
Jon Paris <[email protected]> Mon, 8 Jun 2026 17:40:59 -0400
| Newsgroups | gmane.comp.hardware.ibm.midrange |
|---|---|
| Message-ID | <[email protected]> |
Personally, I'd use the system() function. Much easier to test for errors and determine the root failure message.
Google's AI came up with this example whcih I have not tested but it looks about right.
**free
// Modern control specifications—no bnddir('QC2LE') needed!
ctl-opt dftactgrp(*no);
// Prototype for the C system() function
dcl-pr runCommand int(10) extproc('system');
cmdString pointer value options(*string);
end-pr;
// Import system variable to capture error message IDs
dcl-s errorMsg char(7) import('_EXCP_MSGID');
// Variable to store the return code
dcl-s returnCode int(10);
// Execute a CL command directly
returnCode = runCommand('CLRPFM FILE(MYLIB/MYFILE)');
// Check for execution failure
if returnCode <> 0;
if errorMsg = 'CPF3142'; // File not found
// Handle specific error logic here
endif;
endif;
*inlr = *on;
Jon Paris
[email protected]
> On Jun 8, 2026, at 5:31 PM, James H. H. Lampert via MIDRANGE-L <[email protected]> wrote:
>
> I've got a project in which I will be using a QCMDEXC call to shell out a CRTLF (from a generated source member). What is the easiest way for the calling program to determine whether the CRTLF was successful?
>
> --
> JHHL
> --
> This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
> To post a message email: [email protected]
> To subscribe, unsubscribe, or change list options,
> visit: https://lists.midrange.com/mailman/listinfo/midrange-l
> or email: [email protected]
> Before posting, please take a moment to review the archives
> at https://archive.midrange.com/midrange-l.
>
> Please contact [email protected] for any subscription related questions.
>
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: [email protected]
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: [email protected]
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact [email protected] for any subscription related questions.