|
Hi Birgitta
Yes, the system() function returns an integer, 0 if the command is
successful. And, according to the reference, we have this -
If the system() function fails, the global variable _EXCP_MSGID in
<stddef.h> is set with the exception message ID.
*Regards*
*Vern Hamberg*
IBM Champion 2025 <cid:part1.QtMlKfw5.8YvQHd3C@centurylink.net> CAAC
(COMMON Americas Advisory Council) IBM Influencer 2023
On 6/9/2026 1:53 AM, Birgitta Hauser wrote:
Jon and AIerror code is returned? ;)
How you'd get the CPF-Msg which is checked in the example if only an
(Les Brown)
When using QCMDEXC it is possible to trap the system error message!
Mit freundlichen Grüßen / Best regards
Birgitta Hauser
Modernization – Education – Consulting on IBM i
Database and Software Architect
IBM Champion since 2020
"Shoot for the moon, even if you miss, you'll land among the stars."
"If you think education is expensive, try ignorance." (Derek Bok)them and keeping them!"
"What is worse than training your staff and losing them? Not training
"Train people well enough so they can leave, treat them well enough sothey don't want to. " (Richard Branson)
"Learning is experience … everything else is only information!" (AlbertEinstein)
Jon Paris
-----Original Message-----
From: MIDRANGE-L<midrange-l-bounces@xxxxxxxxxxxxxxxxxx> On Behalf Of
Sent: Monday, 8 June 2026 23:41success/failure
To: Midrange Systems Technical Discussion<midrange-l@xxxxxxxxxxxxxxxxxx>
Subject: Re: Shelling out CRTLF via QCMDEXC -- question about
errors and determine the root failure message.
Personally, I'd use the system() function. Much easier to test for
looks about right.
Google's AI came up with this example whcih I have not tested but it
extproc('system');
**free
// Modern control specifications—no bnddir('QC2LE') needed!
ctl-opt dftactgrp(*no);
// Prototype for the C system() function dcl-pr runCommand int(10)
cmdString pointer value options(*string); end-pr;char(7) import('_EXCP_MSGID');
// Import system variable to capture error message IDs dcl-s errorMsg
midrange-l@xxxxxxxxxxxxxxxxxx> wrote:
// 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
Jon.Paris@xxxxxxxxxxxxxx
On Jun 8, 2026, at 5:31 PM, James H. H. Lampert via MIDRANGE-L<
a CRTLF (from a generated source member). What is the easiest way for the
I've got a project in which I will be using a QCMDEXC call to shell out
calling program to determine whether the CRTLF was successful?
related questions.
--
JHHL
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list To post a message email:MIDRANGE-L@xxxxxxxxxxxxxxxxxx To
subscribe, unsubscribe, or change list options,
visit:https://lists.midrange.com/mailman/listinfo/midrange-l
or email:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives at
https://archive.midrange.com/midrange-l.
Please contactsupport@xxxxxxxxxxxxxxxxxxxx for any subscription
list To post a message email:MIDRANGE-L@xxxxxxxxxxxxxxxxxx To subscribe,--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
unsubscribe, or change list options,
visit:https://lists.midrange.com/mailman/listinfo/midrange-larchive.midrange.com/midrange-l.
or email:MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives athttps://
questions.
Please contactsupport@xxxxxxxxxxxxxxxxxxxx for any subscription related
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/midrange-l.
Please contact support@xxxxxxxxxxxxxxxxxxxx for any subscription related
questions.
This mailing list archive is Copyright 1997-2026 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].
Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.