---+ Using CGI to Interface with the Web APPX understands how to parse CGI data into APPX variables. <br />It picks apart the CGI data string and looks for variable NAMEs that match <br />an APPX variable name and sets the variable accordingly. This acts as a <br />SET statement where the sender is always alpha. So, if you use the ALPHA <br />representation of a DATE field, then when APPX fills the date field from <br />the CGI data, it will do the correct conversion from the ALPHA value.<br /><br />Here is an example of how it works:<br /><br />APPX expects to receive the list of CGI variables on its "stdin", when<br />it is invoked as the action of a form. If you use METHOD=POST for your<br />form, the web server will put the variables into stdin automatically.<br />You just run APPX with desired command line arguments as your ACTION.<br />With METHOD=GET for form CGI data posting, you have to get the variables<br />into "stdin" yourself. On a UNIX web server, you would need to do an<br /><br />echo $QUERY_STRING|appx -d=.....<br /><br />and on a Windows web server, the precise command to do that would<br />depend on your particular server's CGI language.<br /><br />There is also an environment variable, CONTENT_LENGTH, that controls the<br />length of the APPX variable parser. This is not specifically an APPX<br />variable. Rather, it is set automatically by the web server, and APPX<br />checks it to see how far to parse. If you are setting this manually,<br />just make sure it is set equal to or greater than the length of your CGI<br />string. If it is set longer, APPX will stop parsing when it reaches a<br />NULL (0x00). If you use "echo" and also set this length greater than the<br />size of you data string, you will have to be careful of trailing 0x0A<br />characters that "echo" will append for you. There is usually a flag you<br />can give "echo" to tell in not to do this. "man echo" should tell you <br />this if you need it. On some UNIX systems, it is "echo -n".<br /><br />The format of your CGI NAMEs for variables needs to match a pattern that <br />APPX understands. Here is what the parser knows how to decode into APPX<br />variable names:<br /><br />AAA:BBBB BBB(CCC)=DdDdDdDd<br /><br />AAA: is optional. It is the application ID of the APPX variable. If left <br />off, it will default to the application ID of the currently running process <br />at the point the RT_IMPORT_CGIDATA call was made. You can make this call <br />as many times as you like from as many processes as you like. The first <br />time it is called, it actually parses out the CGI names and values into <br />memory. Then it checks the memory array trying to match up APPX variable <br />names. So, if you call it again later, it skips the actual parse/import <br />step and just re-tries to match up and fill APPX variable. <br /><br />The default application ID is not kept from call to call, so you can call <br />it from application AAA and it will try looking in the AAA dictionary. <br />Later if you call it again from application XXX it will try looking in the <br />DD for XXX if no app id was given in the CGI data. Clear as mud?<br /><br />BBBB BBB is the variable name and is required. The embedded spaces can be <br />specified as underscores also and APPX will treat them as spaces.<br /><br />(CCC) is optional and tells APPX which occurrence of a field to set. If <br />used, it should use leading zeroes. So it should be (002) and not (2).<br /><br />These can be given in lower case. APPX will convert to upper case before <br />trying to lookup APPX Dictionary names.<br /><br />The application ID and variable name should be separated by a colon ":" <br />and have no spaces before or after the colon.<br /><br />The occurrence number should be wrapped in parentheses with no embedded <br />spaces or spaces between the variable name and the leading parenthesis.<br /><br />You can use application "---:" also. APPX will understand that you want <br />internal APPX PDFs if it sees this.<br /><br />Once inside the APPX process, you just do:<br /><br />CALL ,RT_IMPORT_CGIDATA<br /><br />... anywhere you need to fill variables from CGI data. You can do it as <br />many times as you need from as many processes within the same APPX session.<br /><br />For debugging, you can set APPX_CGIDATA_LOG=/tmp/cgi.log and APPX will <br />log it's parsing and variable lookup steps and results.<br /><br />In your script that invokes APPX on the web server, be sure that you have<br />specified APPXPATH and any other variables (like APPX_PD_SIGNS or ORAHOME)<br />that you normally need to specify when running APPX.<br /><br /><br />> What do I need to do to get Box A to issue CGI requests to APPX running on Box B and then get the resulting HTML file back to Box A to display on the users browser. <br /><br />Try "rsh" which runs a UNIX shell command on another system and gets back the output for you. We have our web server running on a separate machine from our APPX server and use the following scripts to handle the "rsh" execution.<br /><br />#!/bin/sh<br />##<br />## srvr-post.cgi<br />##<br />## Web server CGI script residing on our web server<br />## machine to handle CGI POST requests.<br />##<br />export QUERY_STRING=`head -c $CONTENT_LENGTH`<br />rsh mozart "appx_server \"$QUERY_STRING\" $REMOTE_HOST"<br /><br />#!/bin/sh<br />##<br />## srvr-get.cgi<br />##<br />## Web server CGI script residing on our web server<br />## machine to handle CGI GET requests.<br />##<br />rsh mozart "appx_server \"$QUERY_STRING\" $REMOTE_HOST"<br /><br />#!/bin/ksh<br />##<br />## appx_server<br />##<br />## Shell script residing on our APPX server machine <br />## to handle running APPX and returning the resulting<br />## HTML data back to the calling script on the web<br />## server machine<br />##<br />export APPX_QUERY_STRING="$1"<br />export REMOTE_HOST="$2"<br />export APPXPATH=/supp/ecr/data<br />export TERM=vt320-k<br />export APPX_HTML_FILE=$RANDOM.html<br />/supp/ecr/appx -a=cts -d=cts -t=subr -p=web_server >/dev/null 2>&1<br />##<br />## See if the resulting file is already in HTML format.<br />## If not, tag with a standard HTML header/trailer.<br />##<br />head /tmp/$APPX_HTML_FILE|grep "Content-type:" >/dev/null 2>&1 <br />if [ "$?" = "1" ]<br />then<br /> cat header.html<br /> tail -c+2 /tmp/$APPX_HTML_FILE<br /> cat trailer.html<br />else<br /> tail -c+2 /tmp/$APPX_HTML_FILE<br />fi<br />rm /tmp/$APPX_HTML_FILE -- Main.JoeOrtagus - 2012-02-13
This topic: Main
>
WebHome
>
SpecialTopics
>
UsingCGItoInterfacewiththeWeb
Topic revision: r1 - 2012-02-13 - JoeOrtagus
Copyright © 2008-2024 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki?
Send feedback