10-24-2012
Debuggund Web Page using REXX
So, is this like JSP with embedded rexx in a proto-page, or is the rexx doing a service as CGI, or the whole web server either inetd or listening?
I believe that rexx is doing the service like CGI. Here is an example of the code:
Code :
. Menu Utilities Compilers Help .
. ------------------------------------------------------------------------------- .
. UC05 E /ZOS111/usr/lpp/websys/racfmain.rexx Line 00000000 Col 001 079 .
. Command ===> Scroll ===> CSR .
. ********************************* Top of Data ********************************** .
. /* REXX */ .
. /* */ .
. /* ==================================================================*/ .
. /* */ .
. /* COMPONENT_NAME: racfmain.rexx */ .
. /* */ .
. /* FUNCTIONS: */ .
. /* */ .
. /* UCOP Password Change - Initial Exec. */ .
. /* ==================================================================*/ .
. .
. .
. tmplname = '' .
. optfield = '' .
. .
. templateStart = 0 .
. templateEnd = 0 .
. .
. /* Use cgiutils to create a standard html header */ .
. 'cgiutils -status 200 -ct text/x-ssi-html' .
. file. = '' /* initialize the stem */ .
. out.= '' .
. .
. env.= "" .
. do i=1 to __environment.0 .
. parse var __environment.i varname '=' data .
. env.varname = data .
. if substr(varname,1,11) = '_BPX_USERID' then racfxid = data .
. end .
. .
. parse var env.SCRIPT_NAME pref '/' application suff '/' . /*@L1A*/ .
. .
. /*Check for the presence of the conf path of the CA domain built from the URI's .
. application string. @L3A*/ .
. .
. domainName=application /*@L3A*/ .
. upper domainName /*@L3A*/ .
. pathName = 'DOCUMENT_ROOT'||domainName /*@L3A*/ .
. .
. /* if the CA Domain path is not set, use the conf path without the .
. the CA Domain name @L3A*/ .
. if env.pathName ='' then do /*@L3A*/ .
. pathName = DOCUMENT_ROOT /*@L3A*/ .
. end /*@L3A*/ .
. .
. /* read template file */ /*@L3C*/ .
. address syscall 'readfile /usr/lpp/websys/racfmain.tmpl file.' .
. .
. if file.0 = 0 | file.0 = '' then .
. say 'RACFAAAI RACF WEB Change: Error in racfmain.rexx: '||, .
. 'Unable to read configuration data' .
. else do .
. /* In case there are leading blanks on the lines, remove them @L2A*/ .
. do i = 1 to file.0 /*@L2A*/ .
. file.i = strip(file.i) /*@L2A*/ .
. end /*@L2A*/ .
. .
/* read the section in template file that has APPLICATION tag
and with NAME=CONTENT here*/
call getsect 'APPLICATION' 'CONTENT' application
if out.0 = -1 then do
say 'RACFAABI RACF WEB Change: Error in racfmain.rexx: '||,
'No application of the name 'application ' exists'
exit 8
end
if out.0 = -2 then do
say 'RACFAACI RACF WEB Change: Error in racfmain.rexx: '||,
'CONTENT tag not found under APPLICATION 'application
exit 8
end
if out.0 = 0 then do
say 'RACFAADI RACF WEB Change: Error in racfmain.rexx: '||,
'Empty CONTENT in APPLICATION 'application
exit 8
end
else /* CONTENT found. Write as HTML unless an INSERT is found */
do i = 1 to out.0
record= strip(out.i) /* trim leading and trailing spaces*/
/* get the string inbetween %% and %% */
parse var record pref '%%' tmplname '%%' suff
/* the value with symbol '-' are not templet name,although they
are so called here. They are some additional info that's
needed in the html file */
if substr(tmplname,1,1) = '-' then
call getinsert tmplname optfield
if tmplname ¬= "" then do
/* Template name found. Write out the rest of the line
so far there's no template name in racfmain page, this
code is for future expending */
say suff
end
else
say record
end
end
exit 0
/*******************************************************************
* Procedure getsect - returns all lines of a specified template *
* section in stem variable out. *
*******************************************************************/
getsect: procedure expose file. out. tmplname typeStartline typeEndline,
templateStart templateEnd application /*@L1C*/
parse arg type section typename
/* application NAME must be upper case @L1A*/
if (type = 'APPLICATION') then do /*@L1A*/
upper typename
end
k= 1
out.= ''
out.0= 0
typetag= '<' || type || ' NAME=' || typename || '>'
typeendtag= '</' || type || '>'
sectiontag= '<' || section || '>'
sectionendtag= '</' || section || '>'
/* If the type is TEMPLATE and we have called getsect TEMPLATE before,
just use the saved value */
if (type = 'TEMPLATE' & templateStart <> 0) then do
typeStartline = templateStart
typeEndline = templateEnd
end
else do
/* find the NAME= type */
do while k <= file.0 & index(file.k, typetag) ¬= 1
k = k + 1
end
typeStartline = k
if k > file.0 then do /* can't find typetag */
out.0 = -1
return
end
/* find the type end tag */
do while k <= file.0 & index(file.k, typeendtag) ¬= 1
k = k + 1
end
typeEndline = k
if k > file.0 then do /* can't find type end tag */
out.0 = -1
return
end
end
/* start to search section end tag from the line following type */
k = typeStartline + 1;
/* find the section end */
do while k <= typeEndline & index(file.k, sectionendtag) ¬= 1
k = k + 1
end
sectionEndline = k
if k > typeEndline then do /* can't find sectionendtag */
out.0 = -2
return
end
/* find section */
k = typeStartline + 1
do while k <= sectionEndline & index(file.k, sectiontag) ¬= 1
k = k + 1
end
if k > sectionEndline then do /* can't find section tag */
out.0 = -2
return
end
/* start at the following line */
k = k + 1
do while k < sectionEndline
if substr(file.k,1,1) ¬= '#' then do
out.0 = out.0 + 1
j = out.0
parse var file.k pref '[' subvar ']' suff
if subvar ¬= "" then do
/* the subvar is tmplname and need to be substituted */
if subvar = "tmplname" & tmplname ¬= "" then
subvar= tmplname
else if subvar = "application" & application ¬= "" then /*@L1A*/
subvar=application /*@L1A*/
else /* it's something else just restore it in [] */
subvar= '[' || subvar || ']'
/* restore the sub in the statement */
out.j= pref || subvar || suff
end
else
out.j= file.k /* assign value to the output stem */
end
k = k + 1
end
return
/*******************************************************************
* procedure getinsert - Writes to output all lines of an INSERT *
******************************************************************/
getinsert: procedure expose file. tmplname application /*@L1C*/
parse arg field optstring /*@L1C*/
j= 1
fprint= 'no'
fdone= 'no'
/* get the substition variable in the [], field is tmplname in calling
function */
parse var field pref '[' subvar ']' suff
/* make it same as in the conf. file */
fieldtag= '<INSERT NAME=' || field || '>'
do while j <= file.0 & fdone = 'no'
frecord= strip(file.j)
/* go through conf. file non-comment lines */
if substr(frecord,1,1) ¬= '#' then do
if fprint = 'no' then do
/* find the matching insert section */
if index(frecord,fieldtag) = 1 then do
fprint= 'yes'
end
end
else if index(frecord,'</INSERT>') = 1 then do
fdone = 'yes'
end
else do
parse var frecord '%%' insertname '%%'
if insertname ¬= "" then
call getinsert insertname
else do
/* Write the record insertion code after making
proper variable substitution */
parse var frecord pref '[' subvar ']' suff
if subvar ¬= "" then do /* @L1A*/
if subvar = "optfield" then do /* @L1C*/
if optstring ¬= "" then
subvar= optstring
else
subvar= ""
end
else if subvar = "tmplname" & tmplname ¬= "" then
subvar= tmplname
else if subvar = "transactionid" then
subvar= ""
else if subvar = "application" & application ¬="" then /*@L1A*/
subvar = application /*@L1A*/
else
subvar= '[' || subvar || ']' /* @L1A*/
say pref || subvar || suff
end
else /* @L1A*/
say frecord
end
end
end
j = j + 1
end
return
Last edited by Franklin52; 10-25-2012 at 05:48 AM ..
Reason: Please use code tags for data and code samples
10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I built my website based on Dreamweaver, on Windows platform. My server uses Unix, and the page doesn't look too good. Is there any way to solve this problem without too much of a headache? (1 Reply)
Discussion started by: PCL
1 Replies
2. UNIX for Dummies Questions & Answers
Hey im new to unix!
I am tryin to create a web page in unix and have done it all but when i try and load it it says permission denied!?>
i have chmod a+rx for folder and file to make sure but still permissions wont let me?!
any ideas can anyone do a quick run through of how to make a web page... (4 Replies)
Discussion started by: shashora
4 Replies
3. UNIX for Dummies Questions & Answers
Hello,
I am new to unix, but wanted to know how can we fetch data from a web page (i.e. an HTML Page), my requirement is to read an html page and wanted to create a flat file (text file) based on the contents available in the mentioned HTML page.
Thanks
Imtiaz (3 Replies)
Discussion started by: Imtiaz
3 Replies
4. UNIX for Dummies Questions & Answers
hey uhh this is my first post and i was wondering
how do i make a web page for like a small business or something
anything will help
thanks (3 Replies)
Discussion started by: Neil Peart
3 Replies
5. Programming
Hello,
I'm a total newbie to HTTP commands, so I'm not sure how to do this. What I'd like is to write a C program to fetch the contents of a html page of a given address.
Could someone help with this?
Thanks in advance! (4 Replies)
Discussion started by: rayne
4 Replies
6. Shell Programming and Scripting
Hi all,
I am having an XML file.
And as per requirement I need to map fields of this file with various field of web page.
So how can I use wput command into it ?
Regards,
gander_ss (3 Replies)
Discussion started by: gander_ss
3 Replies
7. UNIX Desktop Questions & Answers
Is there a way we can get a web page through CLI on a unix machine? Please help! (3 Replies)
Discussion started by: Pouchie1
3 Replies
8. Shell Programming and Scripting
I have a shell script that runs periodic upgrades on machines. I want to print certain echo commands from the shell script onto a webpage. What command in shell should I use for doing this. (1 Reply)
Discussion started by: lassimanji
1 Replies
9. UNIX for Dummies Questions & Answers
Hi,
I have a project for school using wget and egrep to locate pattern locations on a web page.
One of the things we have to do is handle an "access denied" exception.
Here is the problem, I can not think of/find any web pages that give me an access denied error to play with, can anyone suggest... (1 Reply)
Discussion started by: njmiano
1 Replies
10. AIX
nmon and web page !
Is there any way to let nmon be configured with external Web Page and updating the same web page to be graphic monitoring.
Pls advice ... (1 Reply)
Discussion started by: Mr.AIX
1 Replies