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><meta charset="UTF-8"><body>" 8echo "<h1>lwstest script stdout</h1>" 9>&2 echo -n "lwstest script stderr: REQUEST_METHOD was $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 $line" 18 19 echo "read=\"$line\"" 20else 21 echo "<table>" 22 echo "<tr><td colspan=\"2\">/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>$A</td>" 27 echo -e "<td>$B</td></tr>" 28 done 29 echo "</table>" 30fi 31 32echo "<br/>done" 33echo "</body></html>" 34sleep 0.5 35exit 0 36 37