尝试启动脚本但在意外标记“stop”附近不断出现语法错误

尝试启动脚本但在意外标记“stop”附近不断出现语法错误
#!/bin/bash
#

case “$1” in
    start)
        echo -n “Starting Queue Manager”
                /opt/mqm/bin/strmqm QMPROD1
                sleep 10

        echo -n “Started Queue Manager”
        #
        echo “IBM ACE”
                /opt/ace-12.0.4.0/server/bin/mqsistart.bin IIBPROD1
                sleep 10

        echo “Pokrenut ACE”
        ;;
    stop)
        echo -n “Stopping IBM ACE”
                /opt/ace-12.0.4.0/server/bin/mqsistop.bin IIBPROD1

        echo -n “Stop IBM ACE”
                kill -9 'ps -ef | grep ace'

        echo -n “Ok”
        #
        echo -n “Stopping Queue: Queue Manager”
                /opt/mqm/bin/endmqm QMPROD1

        echo -n “Stop”
                kill -9 'ps -ef | grep mqm'
                sleep 10
        ;;
        $0 stop
        $0 start
   *)
        echo “Usage: $0 start | stop”
esac
exit 0

[root@ct init.d]# sh ace.sh start ace.sh: 第 34 行:意外标记stop' ace.sh: line 34: $0 附近语法错误 stop' 我的操作系统是 Centos 8

答案1

我创建了与上面的脚本类似的新脚本。

#!/bin/bash

start() {
   echo "Starting Queue Manager"
   /opt/mqm/bin/strmqm QMPROD1
   sleep 2
   echo -n "Started Queue Manager"
   echo -n "Starting IBM ACE"
   /opt/ace-12.0.4.0/server/bin/mqsistart IIBPROD1
   sleep 2
   echo -n "Started IBM ACE(Svaka Cast)"
}

stop() {
   echo -n "Stopping IBM ACE"
   /opt/ace-12.0.4.0/server/bin/mqsistop IIBPROD1
   sleep 2
   echo -n "Stopped IBM ACE"
   echo "stopping Queue Manager"
   /opt/mqm/bin/endmqm QMPROD1
   sleep 2
   echo "Ugasen Queue Manager"
}

case "$1" in
   start) start ;;
   stop)  stop;;
   *) echo "usage $0 start|stop" >&2
      exit 1
      ;;
esac

相关内容