John McKee wrote:
What I see is using an API to initiate QSH instead of just running QSH 
directly.
I can see the incredible usefulness of this from within RPG or C.  But, 
what is
the advantage from within CLE?
John:
I'm not good at explanation. And being so much an IBM RPG/COBOL kind of 
programmer, the world of Unix and C is often foreign to me. File 
descriptors, library functions, shell operations -- they're like 
speaking a foreign language during the time before learning to think in 
the language.
So, I'll post a basic example in the Midrange code repository --
http://code.midrange.com/8a1a65b440.html
The example code is all ILE CL. A service program is used for the procs 
to open and close the file descriptors used by the API, to make the 
example API code stay focused on the API itself. The program itself 
makes three consecutive calls to the API for three different uses.
The code is kept pretty simple. It's also written at V5R3 since I won't 
be able to upgrade my system to V5R4 for a while, so it doesn't go as 
far as it could.
The purpose is to investigate the meaning of the file descriptors used 
for the API and how they relate to the /concepts/ of stdin, stdout & 
stderr. The file descriptors are used by the API, but they're shown to 
be not quite the same as "STDIN", "STDOUT" & "STDERR". This is 
demonstrated by the overrides to STDOUT & STDERR, and the different 
program outputs that result -- into the streamfiles within the API, but 
into the QPRINT printer files by the C library functions even while they 
intermix with the API.
The program runs as ACTGRP(*NEW) just to make the printer file output 
more accessible when run interactively.
Multiple calls to the API continue to use the same descriptors in the 
example. This isn't required -- each call can have a new set if desired.
The example doesn't do anything useful; it simply shows how to call the 
API while creating a couple forms of output. STRQSH can be much easier 
to use; the API helps make some stuff more visible on how it works on 
System i.
Tom Liotta
As an Amazon Associate we earn from qualifying purchases.