A
Albert van der Horst
I am trying to do some web scripting in Forth
This is a transcript of the perl
example from O'Reilly (Gundavaram) CGI-programming pg. 17.
With the multiple line strings and the occasional
auxiliary word, it looks neater than perl IMO.
However, no environment variables can be accessed from the
script apparently. The corresponding perl script has no
such problems. (Environment available in an associative
array %ENV ).
What is going on here?
[For those unacqainted with CGI, these are scripts that
generates html "on the file". With variable content.]
---------8<----------------8<--------------
#!/usr/bin/lina -s
\ Using server site scripting in Forth.
\ ---------- requisites -----------------
REQUIRE GET-ENV
\ Print environment variable from its NAME.
: .ENV GET-ENV TYPE "<BR>" TYPE CR ;
\ --------- push the scripts prelude --------------
"Content-type: text/html
<HTML>
<HEAD><TITLE> About this server</TITLE></HEAD>
<BODY>
<H1>About this server</H1>
<HR>Welcome to Albert's brave new world of Forth scripting!<HR>
<PRE>
" TYPE
\ --------- push information ---------------------
"Server Name: " TYPE "SERVER_NAME" .ENV
"Running on port: " TYPE "SERVER_PORT" .ENV
"Server SOFTWARE: " TYPE "SERVER_SOFTWARE" .ENV
"Server PROTOCOL: " TYPE "SERVER_PROTOCOL" .ENV
"CGI Revision: " TYPE "GATEWAY_INTERFACE" .ENV
"Server Name: " TYPE "SERVER_NAME" .ENV
"PATH Name: " TYPE "PATH" .ENV
\ --------- push the scripts postlude --------------
"</PRE>
</BODY>
</HTML>
" TYPE
---------8<----------------8<--------------
This is a transcript of the perl
example from O'Reilly (Gundavaram) CGI-programming pg. 17.
With the multiple line strings and the occasional
auxiliary word, it looks neater than perl IMO.
However, no environment variables can be accessed from the
script apparently. The corresponding perl script has no
such problems. (Environment available in an associative
array %ENV ).
What is going on here?
[For those unacqainted with CGI, these are scripts that
generates html "on the file". With variable content.]
---------8<----------------8<--------------
#!/usr/bin/lina -s
\ Using server site scripting in Forth.
\ ---------- requisites -----------------
REQUIRE GET-ENV
\ Print environment variable from its NAME.
: .ENV GET-ENV TYPE "<BR>" TYPE CR ;
\ --------- push the scripts prelude --------------
"Content-type: text/html
<HTML>
<HEAD><TITLE> About this server</TITLE></HEAD>
<BODY>
<H1>About this server</H1>
<HR>Welcome to Albert's brave new world of Forth scripting!<HR>
<PRE>
" TYPE
\ --------- push information ---------------------
"Server Name: " TYPE "SERVER_NAME" .ENV
"Running on port: " TYPE "SERVER_PORT" .ENV
"Server SOFTWARE: " TYPE "SERVER_SOFTWARE" .ENV
"Server PROTOCOL: " TYPE "SERVER_PROTOCOL" .ENV
"CGI Revision: " TYPE "GATEWAY_INTERFACE" .ENV
"Server Name: " TYPE "SERVER_NAME" .ENV
"PATH Name: " TYPE "PATH" .ENV
\ --------- push the scripts postlude --------------
"</PRE>
</BODY>
</HTML>
" TYPE
---------8<----------------8<--------------