将写好的shell脚本放在/www/cgi-bin/目录下
-
#!/bin/sh
-
-
process_query_string()
-
{
-
local i msg _name _val IFS="&"
-
for i in $QUERY_STRING; do
-
_name=${i%=*}
-
[ "$_name" = "$i" ] && _val= || _val=${i#*=}
-
eval $_name=$_val
-
done
-
}
-
-
[ "$REQUEST_METHOD" = "POST" ] && read QUERY_STRING
-
-
process_query_string
-
-
echo "Content-type: text/html;charset=UFT-8"
-
echo ""
-
echo "i am $name ,$age years old"
-
echo "posted data is $QUERY_STRING" >&2
-
~
-
~
-
~
-
root@OpenWrt:/www/cgi-bin# echo "name=john&age=18" | REQUEST_METHOD=POST ./test.cgi
-
Content-type: text/html;charset=UFT-8
-
-
i am john ,18 years old
-
posted data is name=john&age=18
-
root@OpenWrt:/www/cgi-bin#
浏览器输入 />
得到如图:
阅读(3326) | 评论(0) | 转发(0) |