There are many shell script functions to aid in the
production of output. These helper functions are squirreled away
in the wui/cgi-bin/include
directory. Typically they are included within a script in a form
similar to:
. ../include/form.sh . ../include/service.sh
The following sections describe the functions that can be found in each collection.
This file contains a set of shell functions that can aid a developer in generating HTML output and process arguments from forms. It includes the following set of functions:
create_html_ram_disk
Some of the CGI scripts will
produce output files that need to be accessible later
on. This function makes sure that a temporary work area
for these files is available. After invoking this
script, you should be able to use the
ramHtmlDir
environtment variable to
determine the location (at the time of this writing it
was set to /mnt/ram4/html
). It does
not hurt to invoke this function more than once (the
setup is only done one time). This function returns 0 if
the space is available.
filesize
FNAME
This macro prints out the size of file
FNAME
in kilobytes (like "40K") and
returns 0. It prints out "0K" and returns 1 if the file
isnt' found.
html_escape
This function escapes HTML characters using
sed. It acts as a filter. For
example: echo "<p>" |
html_escapeWould result
in:<p>
.
set_query_options
This is an extremely powerful function for parsing
key/value pairs from the QUERY_STRING
environment variable and unescaping the special percent
characters which might appear. For example:
QUERY_STRING='key=Text+To+Submit&host=127.0.0.1' set_query_options
Would find the
key
and host
values and define
QUERY_key
to "Text To Submit
" and
QUERY_host
to "127.0.0.1
".
unpercent
ORIG
This function translates an escaped form parameter
to the ASCII string you want (it converts '+' to ' ' and
'%XX' to single character represented by hex code). For
example unpercent "P+%42"
would yield
"P B"
.
This file contains a set of shell functions that can aid a developer in determining if a certain process or service is running on the system. It includes the following set of functions:
control_service
NAME
start|stop
This function attempts to either
start
or stop
the
service NAME
(for example
sshd
). It also generates
HTML output showing the results of
the attempt.
service_running
NAME
This function returns 0 if the service
NAME
(like sshd
)
appears to be running, or 1 if the service appears to be
stopped. It only works for services which support the
status
option.
service_running_or_show
NAME
LABEL
This function returns 0 if the service
NAME
is already running, otherwise,
it outputs the necessary HTML so that
the user can start the service and returns 1. The
LABEL
is used in the
HTML.