RetroForum Welcome, Guest. Please login or register.
September 09, 2010, 11:23:37 PM
Home Help Search Calendar Login Register

RetroForth Discussion  |  Main  |  Discussion  |  Topic: How to run a retroforth cgi « previous next »
Pages: 1 Go Down Print
Author Topic: How to run a retroforth cgi  (Read 898 times)
stevetsai
Member
**

Karma: +0/-0
Offline Offline

Posts: 8


View Profile
How to run a retroforth cgi
« on: December 24, 2005, 02:38:42 PM »

dear Charles,

Can you give me examples of retroforth cgi scripts?

thanks,

Steve Tsai
Logged
Charles Childers
Administrator
Sr. Member
*****

Karma: +2/-0
Offline Offline

Posts: 745


View Profile WWW
Re: How to run a retroforth cgi
« Reply #1 on: December 24, 2005, 07:26:22 PM »

I've only recently started exploring options for real CGI work in RetroForth. (At this point I'm using a combined bash shell script and the development builds of RetroForth 8.3 (see http://rf.fcode.org/get -- the development builds help because they support the command line arguments)


Anyway, a very simple example script:

Code:
#!/bin/bash
echo Content-type: text/html
echo
/path/to/rf $1 bye

If this was in your "cgi-bin" directory as "simple.fs", you could test it with:

Code:
http://server.com/cgi-bin/simple.fs?words

The example script will evaluate the first command line option as a forth word. I'd recommend that you not use this script on a public server as it could be abused, but it does show the basic concept.

The binary will provide a couple of command line related words (cmdline and
Code:
#args
) which return a pointer to the command line and the number of arguments on the command line. Processing that data is up to your code though... (Note that RetroForth will evaluate the command line that's passed to it. Use something like:

Code:
/path/to/rf -f myscript.forth ( .... actual data you want to process in your app .... ) bye


Or:

Code:
/path/to/rf -f myscript.forth bye .... actual data you want to process in your app ....

To load and run "myscript.forth". You'll need to locate where your data starts in the command line and then proceed from there.

I hope this helps somewhat.
Logged
Pages: 1 Go Up Print 
RetroForth Discussion  |  Main  |  Discussion  |  Topic: How to run a retroforth cgi « previous next »
Jump to:  


Login with username, password and session length

Powered by MySQL Powered by PHP Powered by SMF 1.1 RC2 | SMF © 2001-2005, Lewis Media Valid XHTML 1.0! Valid CSS!