This is my simple cgi.serviceporgram for my favorit platform IBMi.
This servieprogram handle the incoming and outgoing streams to std-io.
-
Copy sourcefiles and compile them in your own library
-
Start your admin-server:
STRTCPSVR SERVER(*HTTP) HTTPSVR(*ADMIN)
-
Create a new HTTP-Server instance
-
Add the following parts to the http-config
ScriptAliasMatch /targetlib/(.*) /qsys.lib/targetlib.lib/$1
Auth against the IBMi - Userprofiles:
<Directory /qsys.lib/targetlib.lib>
SetEnv QIBM_CGI_LIBRARY_LIST "targetlib;YAJL;QHTTPSVR"
AuthType Basic
AuthName "Restricted Area"
PasswdFile %%SYSTEM%%
UserID %%CLIENT%%
Require valid-user
</Directory>
or without IBMi Userprofile with a validation-list:
Create a validation list on your IBMi with: CRTVLDL TARGETLIB/TEST
.
Change the http-conf to the following:
<Directory /qsys.lib/targetlib.lib>
SetEnv QIBM_CGI_LIBRARY_LIST "targetlib;YAJL;QHTTPSVR"
AuthType Basic
AuthName "Restricted Area"
PasswdFile targetlib/test
Require valid-user
</Directory>
Add the allowed users with the http-admin "Advanced" - "Internet-user"
-
Start your new http-server
-
Try out the delivered examples:
User informations
https://yourIP:port/targetlib/userinfos?usrcls=secofr&exppwd=1&enabled=0
Active jobs:
https://yourIP:port/targetlib/activejobs?sbs=qbatch&jobsts=msgw
Object locks:
https://yourIP:port/targetlib/objectlocks?lib=testlib&obj=customers
History log infos:
https://yourIP:port/targetlib/historylogs?start=2021-07-11&end=2021-07-12&query=brc
Job log infos:
https://yourIP:port/targetlib/joblogs?job=067435/QUSER/QZDASOINIT&limit=20
Object statistic infos:
https://yourIP:port/targetlib/objectinfos?lib=yajl&objtype=*file
Or try them with my small windows app written in vb.net:
https://github.com/PantalonOrange/Control-for-IBM-i
-
getHTTPInput: Reads the stream and fill in the neccessary variables like "REQUEST_METHOD" and so on.
These values are written to the "INPUTPARMDS" variable. -
writeHTTPOut: Here we can write to the io-std
-
getHTTPHeader: Simple procedure to determine the HTTP header
-
getValueByName Get the value by name from parameters
-
vtranslateData: Convert data between different CCSID's.
ICONV is used for translation. -
parseQueryString: The "QUERY_STRING" is parsed here.
"id=1&test=5" becomes DS [id=1], [test=2] -
seperateValues: The parsed data from "parseQueryString" are simplified here even further.
"id=1" or "test=5" becomes DS [{id}{1}] or [{test}{5}]