1#!/bin/sh
2
3echo -e -n "content-type: text/html\x0d\x0a"
4echo -e -n "transfer-encoding: chunked\x0d\x0a"
5echo -e -n "\x0d\x0a"
6
7echo "<html><body>"
8echo "<h1>lwstest script stdout</h1>"
9>&2 echo "lwstest script stderr: $REQUEST_METHOD"
10
11echo "<h2>REQUEST_METHOD=$REQUEST_METHOD</h2>"
12
13if [ "$REQUEST_METHOD" = "POST" ] ; then
14	>&2 echo "lwstest script stderr: doing read"
15	echo "CONTENT_LENGTH=$CONTENT_LENGTH"
16	read -n $CONTENT_LENGTH line
17	>&2 echo "lwstest script stderr: done read"
18
19	echo "read=\"$line\""
20else
21	echo "<table>"
22	echo "<tr><td colspan=\"2\" style=\"font-size:120%;text-align:center\">/proc/meminfo</td></tr>"
23	cat /proc/meminfo | while read line ; do
24		A=`echo "$line" | cut -d: -f1`
25		B=`echo "$line" | tr -s ' ' | cut -d' ' -f2-`
26		echo -e "<tr><td style=\"background-color:#f0e8c0\">$A</td>"
27		echo -e "<td style=\"text-align:right\">$B</td></tr>"
28	done
29	echo "</table>"
30fi
31
32echo "<br/>done"
33echo "</body></html>"
34
35exit 0
36
37