zl程序教程

您现在的位置是:首页 >  其他

当前栏目

记一个简单的保护if 的sh脚本

保护 一个 简单 脚本 if sh
2023-09-14 08:57:01 时间

 

真是坑爹,就下面的sh,竟然也写了很久!

 

if [ `pwd` != '/usr/xx/bin/tomcat' ] 
    then
        echo "rstall is not allowed in current dir : `pwd` !"
        return
fi

./bin/rstmst.sh;../tomcat-bb/bin/rstns.sh

 

if 的语法真麻烦, linux if 的语法真是服了!

if 后面跟的是 [] ,  而不是 ()  擦!

if 和 then 之间必须换行! ———— 这哪里有写??  这我怎么想得到?

return不能用exit代替,否则退出shell。。。

 

 

then 和 具体语句之间也必须换行!

结尾是fi !