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 similar.

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, what
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 data
area, etc. What do you people do ?

Thanks !

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 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.