I'm writing a shell script to start a Zookeeper
server and write logs in zookeeper.out
nohup
file, but when I try to start it, the following error appears:
> : not foundh: 2: zookeeper.sh:
: not foundh: 8: zookeeper.sh:
: not foundh: 10: zookeeper.sh:
---- Starting Zookeeper ----
: not foundh: 12: zookeeper.sh:
: not foundh: 13: zookeeper.sh: }
: not foundh: 14: zookeeper.sh:
---- Stopping Zookeeper ----
: not foundh: 17: zookeeper.sh:
: not foundh: 18: zookeeper.sh: }
: not foundh: 19: zookeeper.sh:
: not foundh: 21: zookeeper.sh: stop
: not foundh: 22: zookeeper.sh: start
: not foundh: 23: zookeeper.sh: }
: not foundh: 24: zookeeper.sh:
zookeeper.sh: 25: zookeeper.sh: Syntax error: word unexpected (expecting "in")
I can't seem to understand what I'm doing wrong.
Script:
#!/bin/sh
JAVA_HOME=""
KAFKA_HOME="/home/ubuntu/maxFlow/kafka_2.12-1.1.0"
APP_HOME="/home/ubuntu/maxFlow/"
APP_NAME=max-flow-0.0.1-SNAPSHOT
APP_PORT=80
start() {
echo "---- Starting Zookeeper ----"
nohup $KAFKA_HOME/bin/zookeeper-server-start.sh $KAFKA_HOME/config/zookeeper.properties > /dev/null 2>&1 & > zookeeper.out
}
stop() {
echo "---- Stopping Zookeeper ----"
nohup $KAFKA_HOME/bin/zookeeper-server-stop.sh > /dev/null 2>&1 & > zookeeper.out
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "No case"
exit 1
;;
esac
exit 0;
I took the syntax for the script from https://www.shellscript.sh/case.html
. Thank you