I have made fallowing script for CGI scripting learning purpose:
Code:
#!/bin/sh
echo "Content-type: text/html"
echo
CMD=`echo "$QUERY_STRING" | sed -n 's/^.*cmd=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
echo "<html>"
echo "<head><title>Hello CGI</title></head>"
echo "<body>"
function testing {
/bin/pwd
}
if [ $CMD ]
then
case "$CMD" in
ifconfig)
echo "Output of ifconfig :<pre>"
/sbin/ifconfig
testing
echo "</pre>"
;;
uname)
echo "Output of uname -a :<pre>"
/bin/uname -a
echo "</pre>"
;;
*)
echo "Unknown command $CMD<br>"
;;
esac
fi
echo "Choose which command you want to run"
echo "<form method=get>"
echo "<input type=radio name=cmd value=ifconfig checked> ifconfig <br>"
echo "<input type=radio name=cmd value=uname> uname -a <br>"
echo "<input type=submit>"
echo "</body>"
echo "</html>"
Could somebody explain, what relations are between those lines:
CMD=`echo "$QUERY_STRING" | sed -n 's/^.*cmd=\([^&]*\).*$/\1/p' | sed "s/%20/ /g"`
if [ $CMD ]
case "$CMD" in
echo "<input type=radio name=cmd value=ifconfig checked> ifconfig <br>"
echo "<input type=radio name=cmd value=uname> uname -a <br>"
This script works fine, but actually I quite don't understand it's inner working about those radio buttons
Any explanations?