7 Uploading and Running Scripts
This section deals with WebScript scripts, the built-in scripting language in the WebNet.
More details, both on CGI scripts in general and WebScript in particular, can be found in
[5].
7.1 What are Scripts For?
Scripts are used in the WebNet to create dynamic webpages. Static web pages are written
purely in HTML [8], and their contents are thus constant betweenaccesses. Dynamic web
pages are generated at access-time by a script, and can thus present contentthat changes
over time. The script executes on the server, and can thus manipulate server resources and
things that is connected to it – which is interesting when the serveris a WebNet connected
to some appliance.
When the script is executed by the server, the script sends the output to the browser
connecting to it. Thus, the script’s job is to generate some meaningful html code for the
browser to display.
7.2 Types of WebPages
Besides the purely static pages, we can distinguish between “read-only” dynamic webpages
and dynamic webpages with side-effects on the server:
A simple dynamic “read-only” web page typically contains a static “header” part (html-
header and whatever goes on the top of the page), a dynamic “contents” part (the auto-
generated part) and a static “footer” part (whatever goes on the bottom of the page).
A dynamic web page with side-effects typically contains (among other things) forms, and
on the basis on data supplied by the user in these forms it runs different code on the server,
possibly changing items in a database, or controlling attached hardware.
7.3 Example Script
A simple script generating a dynamic read-only web page could look like in Figure 21
(similar to an example in [5]). The line numbers are for textual reference only, they are not
part of the code. The script lists the current TCP configuration:
Line 1 prints the necessary html header information and the title. Line 2 prints the page
headline. Line 3 starts the table definition. 4-7 is a loop that iterates over the contents of
the tcp directory (residing in the etc directory). For each entry it starts a new table row,
a new column, prints the parameter name, makes a new column with a colon in it, makes
a new column with the parameter value in it, and finally prints a newline. In line 8, the
table, the body part and the whole html page are finished.
You can try this script by typing it into the WebScript debugging tool (see section 6.5).
Otherwise you can type it into a file, upload it to the WebNetand run it there – see section
WebNet User’s Guide 31