当前位置: 技术问答>linux和unix
大家帮我看下这段shell脚本!!
来源: 互联网 发布时间:2016-07-19
本文导语: 脚本如下: #!/bin/bash # # # # # # set -x start() { echo $"insmoding $binmodule ..." insmod WAPSUserAgentService.o dbg_mask=31 self_path=/root/WAPSLinux-Nopage/WAPSLinux-Nopage waps_dpath=0x10 if [$? eq 0 ] then printf "insmod success" else print "insmod...
脚本如下:
#!/bin/bash
#
#
#
#
#
#
set -x
start()
{
echo $"insmoding $binmodule ..."
insmod WAPSUserAgentService.o dbg_mask=31 self_path=/root/WAPSLinux-Nopage/WAPSLinux-Nopage waps_dpath=0x10
if [$? eq 0 ]
then
printf "insmod success"
else
print "insmod fail"
fi
}
stop()
{
echo $"rmmoding $binmodule ..."
"$binrmmod" "$binrmmodule"
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $"unload $binmodule successfully ."
else
echo $"unload $binmodule failed with $RETVAL ."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
esac
exit 0
执行说是if [$? eq 0 ]语法错误, 小弟才学习shell不久。这个问题困扰了很久,请大家帮忙解决下。
#!/bin/bash
#
#
#
#
#
#
set -x
start()
{
echo $"insmoding $binmodule ..."
insmod WAPSUserAgentService.o dbg_mask=31 self_path=/root/WAPSLinux-Nopage/WAPSLinux-Nopage waps_dpath=0x10
if [$? eq 0 ]
then
printf "insmod success"
else
print "insmod fail"
fi
}
stop()
{
echo $"rmmoding $binmodule ..."
"$binrmmod" "$binrmmodule"
RETVAL=$?
if [ $RETVAL -eq 0 ]; then
echo $"unload $binmodule successfully ."
else
echo $"unload $binmodule failed with $RETVAL ."
fi
}
case "$1" in
start)
start
;;
stop)
stop
;;
*)
echo $"Usage: $0 {start|stop}"
exit 1
esac
exit 0
执行说是if [$? eq 0 ]语法错误, 小弟才学习shell不久。这个问题困扰了很久,请大家帮忙解决下。
|
“[”之后加个空格试试:
if [ $? eq 0 ]
if [ $? eq 0 ]
|
楼主的if语句没有问题了,不过
print "insmod fail"
应该为
printf "insmod fail"
print "insmod fail"
应该为
printf "insmod fail"