语法错误:未终止的带引号的字符串

时间:2016-03-21 20:14:54

标签: node-red

我正在尝试创建一个init.d文件,以便在启动时启动node-red。我正在使用以下脚本,但不断收到错误“语法错误:未终止引用的字符串”。我无法弄清楚哪一行缺少报价。我尝试在“node-red”中添加引号,但它仍然不起作用。我很感激任何帮助。

#! /bin/sh
# Starts and stops Node-RED
# /etc/init.d/node_red
### BEGIN INIT INFO
# Provides:     node_red
# Required-Start:       $syslog
# Required-Stop:        $syslog
# Default-Start:        2 3 4 5
# Default-Stop:         0 1 6
# Short-Description:    Node-RED initialisation
### END INIT INFO
# Note: this runs as the user called pi

PIDFILE=/var/run/nodered.pid

#Load up node red when called
case "$1" in

start)
        echo "Starting Node-Red.."
        su -l pi -c cd "node-red; screen -dmS red node --max-old-space-size=64 red.js
        echo `screen -ls red | sed -n '2p' | cut -f1 -d.` > $PIDFILE
# or
        #nohup node --max-old-space-size=128 red.js > /var/log/node-red.log &
        #echo $! > $PIDFILE
;;

stop)
        echo "Stopping Node-Red.."
        su -l pi -c "screen -S red -X quit"
# or
        #kill `cat $PIDFILE`
        rm -f $PIDFILE
;;

restart)
        echo "Restarting Node-Red.."
        $0 stop
        $0 start
;;
*)
        echo "Usage: $0 {start|stop|restart}"
        exit 1
esac

1 个答案:

答案 0 :(得分:0)

如评论中所述,问题是echo "Starting Node-Red.."

之后的一行

您需要将开头“移至CD之前,并在该行末尾添加结束”:

...
case "$1" in

start)
        echo "Starting Node-Red.."
        su -l pi -c "cd node-red; screen -dmS red node --max-old-space-size=64 red.js"
        echo `screen -ls red | sed -n '2p' | cut -f1 -d.` > $PIDFILE
# or
        #nohup node --max-old-space-size=128 red.js > /var/log/node-red.log &
        #echo $! > $PIDFILE
;;
...