cgi scripting help needed

hi all,

i'm new to CGI scripting.

I want to compute memory utilisation,
so when i run free command in my cgi scipt,
if memory is utlised more than 70%.

i want to display in free command in html as red color
free
total used free shared buffers cached
Mem: 16438364 15484884 953480 0 392996 9730932
-/+ buffers/cache: 5360956 11077408
Swap: 8385920 91092 8294828
else
I want to show it in green color
free
total used free shared buffers cached
Mem: 16438364 15484884 953480 0 392996 9730932
-/+ buffers/cache: 5360956 11077408
Swap: 8385920 91092 8294828

Here is some example template to make html, also how to use cgi variables = look env

#!/bin/ksh
cat <<EOF
Content-type: text/html

<html>
<body>
$QUERY_STRING
- all other values, look env variables
$(env)
<hr>
EOF

style="color:red;"
# make your calculation here
# then output
((value < 70 ))  && style="color:green;"

cat <<EOF
You can call cmd also<br />
Date: $( date '+%Y-%m-%d %H:%M:%S' ) <br />

<div style="$style">
free .
total used free shared buffers cached
$somevariable and  $var2 ...
Put your data here with variables
</div>

HERE is nice template method ex. using in cgi-scripts.
</body>
</html>
EOF