#!/bin/ksh APPX_RESULT=/tmp/$RANDOM.html export APPXPATH=/users/appx/data /users/appx/appx -a=WWW -d=WWW -t=OUTPUT -p=APPX_HOME_PAGE >/dev/null echo "Content-type: text/html" echo "" cat $APPX_RESULT rm $APPX_RESULTNote: If you are running on an APPX Promotional license, or any other license type that presents a start-up message screen (Release 4.1.8 and higher), the command above that invokes APPX must also include the "session flag", entered as -session or -s. It should look like this:
/users/appx/appx -a=WWW -d=WWW -t=OUTPUT -p=APPX_HOME_PAGE -s >/dev/nullThis will suppress all attempted screen displays by internally issuing an END option whenever a screen is presented. Two cautions: (1) If you're invoking a job that includes a disposition process, the END issued when the disposition runs will cancel the job, so be sure to remove any disposition processes from the job that you execute; (2) Release 4.1.8 had a bug that caused this to cancel the entire session, so upgrading to a newer release is required. You can call this script appxhome.cgi and when it is requested by a browser, the server will run the script to get the document. There is a little bit of trickery going on within the APPX process to get the print file back to the server. So, let us review the script a line at a time:
New URL = "/appx.cgi?DOCID=APPX+HOMEPAGE" #!/bin/ksh APPX_RESULT=/tmp/$RANDOM.html export APPXPATH=/users/appx/data /users/appx/appx -a=WWW -d=WWW -t=SUBR -p=APPX_WEB_SERVER >/dev/null cat $APPX_RESULT rm $APPX_RESULTWe have moved the Content-type lines into APPX for more control. That way, we are not limited to a certain document type. The APPX process can now decide if we are serving text/plain or text/html. Another thing you may seem to be missing here. How does the APPX subroutine know what document is being requested? This information will be pulled from the value of the DOCID field referenced in the URL ('APPX+HOMEPAGE' in this case). You may also notice that our URL in this example does not contain the Application / Database / Process-Type / Process Name of the APPX process we want to run. We could do this, but creating a translation table file within your APPX server application makes the document less complex and increases security. This way, someone can't edit your document source within their browser and run some process you don't want them to run.
CALL ,RT_IMPORT_CGIDATA RESIDENT? Y END? N FAIL 0Refer to the documentation on the Import CGI Data API for a discussion of how APPX will map the variables on the URL to APPX fields. After this step, the APPX work field DOCID in the current application will contain 'APPX+HOMEPAGE'
WEB-99 web server Page: 1 JPN 04/05/16 14:58 Files / Fields Technical Documentation -Options-- File Descriptive Name Org File Type T DP AA RP ======== ============================== ======= ===================== ========== DOCUMENT Server Documents INDEXED PERMANENT Added by PHB on 5/1/1998 12:02 Changed by GLR on 4/20/2000 14:38 Fld D --Stored--- -Options-- Seq No Field Name Typ Format S Start Len D DL AA KC ------- ---------------------- --- ----------------- - ----- ----- ---------- 100 DOCUMENT ID Dom X(30) 1 1 30 P 200 DOCUMENT AP Dom X(3) 1 31 3 300 DOCUMENT DB Dom &&& 1 34 3 400 DOCUMENT TYPE Dom X(10), Tbl 1 37 1 500 DOCUMENT NAME Dom X(30) 1 38 30 600 DOCUMENT ACCESS Dom X(20) 1 68 20 A End of Technical Documentation (Files / Fields)
SET --- NEXT APPLICATION = WEB DOCUMENT AP SET --- NEXT PROCESS NAME = WEB DOCUMENT NAME SET --- NEXT DATABASE = WEB DOCUMENT DB * IF WEB DOCUMENT TYPE EQ JOB T JOB RELATED END? N FAIL 0 IF WEB DOCUMENT TYPE EQ OUTPUT T OUTPUT RELATED END? N FAIL 0 IF WEB DOCUMENT TYPE EQ UPDATE T UPDATE RELATED END? N FAIL 0 IF WEB DOCUMENT TYPE EQ STATUS T STATUS RELATED END? N FAIL 0 IF WEB DOCUMENT TYPE EQ SUBROUTINE T SUBR RELATED END? N FAIL 0 RETURNNotice that we aren't testing for Input, Menus, etc. There is no reason to invoke any interactive process via CGI, so we skip those. It only makes sense to invoke a process that can create a file to return to the web server.
PASS APPX_RESULT FIELD SHARE? Y PASS --- TEMP 256 FIELD SHARE? N GOSUB --- .ENV GET ENV VARIABLEWe are using the .ENV GET ENV VARIABLE API to get the value. If you are running a pre 5.1 version of APPX, you can use the ,RT_GETENV call. This will return the value of APPX_RESULT into --- TEMP 256. Now we can move our print file to the location the web server is expecting:
PASS --- TEMP 80 FIELD SHARE? Y PASS --- PRINT FILE PATHNAME FIELD SHARE? N PASS --- TEMP 256 FIELD SHARE? N GOSUB --- .FILE MOVEWe are using the .FILE MOVE API to move the file for us. If you are running a pre 5.1 version, you can use the following (assuming a Linux/Unix host):
SET --- TEMP 132 = mv APPEND --- TEMP 132 1 --- PRINT FILE PATHNAME APPEND --- TEMP 132 1 --- TEMP 256 APPEND --- TEMP 132 1 >/dev/null 2>&1 SET --- NEW PAGE AFTER = N RUN --- TEMP 132 END? N FAIL 0