cgi获取地址栏参数
脚本:
#!/bin/bash#get.cgiecho "content-type:text/html;charset=utf-8"echo #include html codeecho "<html>"echo "<head>"echo "<style>"echo "*{font-family:宋体}"echo "</style>"echo "</head>"echo "<body>"echo "<pre>"qs=$QUERY_STRINGline=`echo $qs|sed 's/&/ /g'`for loop in $linedoname1=`echo $loop|sed 's/=/ /g'|awk '{print $1}'`value1=`echo $loop|sed 's/=/ /g'|awk '{print $2}'|sed 's/+/ /g'|sed -e 's/%\(\)/\\\x/g'`str=`printf "${name1}='${value1}'"`eval $strdoneecho $idecho $nameecho "</pre>"echo "</body>"echo "</html>"注:在name1中sed 's/=/ /g'表示将地址栏中的等号替换为空格在value1中sed 's/+/ /g'表示将地址栏中的加号替换为空格,sed -e 's/%\(\)/\\\x/g'表示将地址栏中的ASCII字符进行转换
测试结果:
发表回复
评论列表(0条)