CGI传参问题

在学习CGI的过程中,遇到一个关于控制LED亮灭的问题。该问题是从网页上获得参数,在CGI中根据获得的参数重新赋值。源程序如下。该问题为:在第二个赋值的时候,如果把关于off的判断放在后面,无论获得的值是on还是off,所有关于period的赋值都为1;但是把off的判断放在前面,获得on时,period的赋值为1,获得off时,period的赋值为0.这是为什么?

#!/bin/sh

/etc/rc.d/init.d/leds stop

#type=1

#period=1

case $QUERY_STRING in

       *led1*)

              type=1

              ;;

       *led2*)

              type=2

              ;;

       *led3*)

              type=3

              ;;

       *led4*)

              type=4

              ;;

esac

case $QUERY_STRING in

       *off*)

              period=0

              ;;           

       *on*)

              period=1

              ;;

#     *off*)

#            period=0

#            ;;

esac

/bin/cat /web/aaa.template

/sbin/leds $type $period

echo "$type      "

echo "$period    "

echo "Content-type: text/html; charset=gb2312"

echo

#/bin/cat led-result.template

exit 0

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值