Riverwatcher Active Content Environment

RACE Documentation:


Writing Shell Scripts in RACE

For the most part, writing shell scripts in RACE is exactly the same as writing server-side web scripts. In this section, we will discuss the few differences that you should be aware of when writing RACE shell scripts.

From a command line, you can type race and press enter. Assuming the RACE shell in install in your path, you will be dropped into the race shell environment, you can type any valid RACE code and press control-D when you are done and you will see the result of executing the RACE code you just typed.

You can also from the UNIX command line type race followed by the name of a RACE script to execute that script on the fly. Finally, you can also embed the path of your race interpreter in the first line of your script then set the execution bit to on, then you can execute the script directly by typing the script name on the command line. Create a file called helloworld.race in your text editor of choice and put the following lines in it.

#!/usr/local/bin/race

<output>Hello world!</output>

Then type
chmod a+rx helloworld.race
./helloworld.race

One significant difference in behavior when running a RACE shell script is that by default the output is turned off. Note how we wrapped "Hello world!" in the output tag. Had we be writing a web server script, we would not have to do that. If you prefer to have the output on by default, you can use the system tag, e.g.:

<system output="on">

Also, by default all output when running as a shell script is unbuffered. Buffered output means that the output of the script will be displayed all at once at when the script finishes running. While this is the desired behavior when you are running a web server script, most shell scripts are more interactive in nature. You can turn buffered output on by using the system tag, e.g.:

<system output="buffered">


RACE Documentation



 
Copyright 2009 Riverwatcher, Inc. Hosting by Riverwatcher Studios