In fact I have not found any news about it ...
I was interested in knowing if someone had faced the problem and if he had solved it

Il lunedì 17 gennaio 2022, 17:27:06 CET, Dave <dfx1@xxxxxxxxxxxxxx> ha scritto:

Thanks Scott,

If the program has crashed in production and the job is waiting for a
response to a message, then the environment variable route won't work. If I
use a data area or file, I can switch to debug mode and maybe get the
program to end correctly.

On Wed, 12 Jan 2022 at 01:56, Scott Klement <web400@xxxxxxxxxxxxxxxx> wrote:

Hi Dave,

I would typically create an environment variable.  These work great for
CGI programs because you can set them in the Apache httpd.conf file, and
they can be set separately for different <Directory>, <Location>, etc
containers as needed.

So for example, I might do something like this:


    Require all granted
    SetEnv API_LOG_FILE /var/apitest/requestData.txt

The important part is API_LOG_FILE -- in this example, programs in the
SKTESTAPI library will log their data to the
/var/apitest/requestData.txt file.  If API_LOG_FILE isn't defined for a
program, it would be in "production" mode and wouldn't log anything.

Then in the program I would do something like this:

dcl-pr getenv pointer EXTPROC('getenv');
    name pointer value options(*STRING);

dcl-s logFile varchar(2048);
dcl-s ptr pointer;
dcl-s log int(10) inz(-1);
ptr = getenv('API_LOG_FILE');
if ptr = *null;
    // no log needed
    logFile = %str(ptr);
    log = open( logFile
                + O_TEXTDATA + O_TEXT_CREAT + O_CCSID
              : 0
              : 1208
              : 0);

I included the prototype for "getenv" (get environment variable) in case
you didn't already have it.  Typically, I'd have this in a copybook or

As always, in computer programming, there are many ways to accomplish
the same thing, but this way has always worked nicely for me.  It's much
more versatile than something like a data area because it can be defined
in different places with different values in your httpd.conf

Good luck!

On 1/10/2022 11:40 AM, Dave wrote:

At the moment, during testing, each time my CGI programme receives JSON
data, I'm saving it to the IFS.

As I won't need to keep the JSON data once the application is deployed,
would be the best way to dynamically turn on and off the save function of
the program in case it were needed? Seems to me there are many ways of
doing it. I could configure an environment variable, an URL,  change a
area, etc. What do you people do ?

Thanks !
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
To post a message email: WEB400@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
or email: WEB400-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives

As an Amazon Associate we earn from qualifying purchases.

This thread ...


Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2022 by 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.