lws-cgi-test.sh 896 B

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