× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



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

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:

ScriptAlias /apitest /QSYS.LIB/SKTESTAPI.LIB/MYPGM.PGM

<Directory /QSYS.LIB/SKTESTAPI.LIB>
    Require all granted
    SetEnv API_LOG_FILE /var/apitest/requestData.txt
    SetEnv QIBM_CGI_LIBRARY_LIST "TESTDB;SKUTILS"
</Directory>

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);
end-pr;

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
else;
    logFile = %str(ptr);
    log = open( logFile
              : O_CREAT + O_TRUNC + O_INHERITMODE + O_WRONLY
                + O_TEXTDATA + O_TEXT_CREAT + O_CCSID
              : 0
              : 1208
              : 0);
endif;

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:
Hi,



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 !
--
This is the Web Enabling the IBM i (AS/400 and iSeries) (WEB400) mailing
list
To post a message email: WEB400@xxxxxxxxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: https://lists.midrange.com/mailman/listinfo/web400
or email: WEB400-request@xxxxxxxxxxxxxxxxxx
Before posting, please take a moment to review the archives
at https://archive.midrange.com/web400.



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

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

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