Skip to content
Snippets Groups Projects
lws-cgi-test.sh 944 B
Newer Older
  • Learn to ignore specific revisions
  • Andy Green's avatar
    cgi
    Andy Green committed
    #!/bin/sh
    
    
    Andy Green's avatar
    Andy Green committed
    echo -e -n "content-type: text/html\x0d\x0a"
    echo -e -n "transfer-encoding: chunked\x0d\x0a"
    
    Andy Green's avatar
    Andy Green committed
    echo -e -n "\x0d\x0a"
    
    echo "<html><body>"
    echo "<h1>lwstest script stdout</h1>"
    
    Andy Green's avatar
    Andy Green committed
    >&2 echo "lwstest script stderr: $REQUEST_METHOD"
    
    Andy Green's avatar
    cgi
    Andy Green committed
    
    
    Andy Green's avatar
    Andy Green committed
    echo "<h2>REQUEST_METHOD=$REQUEST_METHOD</h2>"
    
    Andy Green's avatar
    cgi
    Andy Green committed
    
    if [ "$REQUEST_METHOD" = "POST" ] ; then
    
    Andy Green's avatar
    Andy Green committed
    	>&2 echo "lwstest script stderr: doing read"
    	echo "CONTENT_LENGTH=$CONTENT_LENGTH"
    	read -n $CONTENT_LENGTH line
    	>&2 echo "lwstest script stderr: done read"
    
    
    Andy Green's avatar
    cgi
    Andy Green committed
    	echo "read=\"$line\""
    
    Andy Green's avatar
    Andy Green committed
    	echo "<table>"
    	echo "<tr><td colspan=\"2\" style=\"font-size:120%;text-align:center\">/proc/meminfo</td></tr>"
    	cat /proc/meminfo | while read line ; do
    		A=`echo "$line" | cut -d: -f1`
    		B=`echo "$line" | tr -s ' ' | cut -d' ' -f2-`
    		echo -e "<tr><td style=\"background-color:#f0e8c0\">$A</td>"
    		echo -e "<td style=\"text-align:right\">$B</td></tr>"
    	done
    	echo "</table>"
    
    Andy Green's avatar
    cgi
    Andy Green committed
    fi
    
    
    Andy Green's avatar
    Andy Green committed
    echo "<br/>done"
    echo "</body></html>"
    
    Andy Green's avatar
    cgi
    Andy Green committed
    
    exit 0