start-stop-daemon quoted arguments misinterpreted

前端 未结 4 566
太阳男子
太阳男子 2020-12-31 01:01

I have been trying to make an init script using start-stop-daemon. I am stuck on the arguments to the daemon. I want to keep these in a variable at the top of the script but

4条回答
  •  执笔经年
    2020-12-31 01:39

    I thought I'd post the final quotations used in my working init script:

    COMMAND="/path/to/script -opt param param2 param3"
    DAEMON_OPTS=" 0.0.0.0:$PORT -dest $OUTPUT_DIRECTORY -command"
    
    start-stop-daemon --start --background --make-pidfile --pidfile $PID --exec $DAEMON -- $DAEMON_OPTS "\"$COMMAND\""
    

    Obviously an incomplete and non-functional example but I hope you get the gist of it. The double quotations with the inner pair escaped is what did the trick.

提交回复
热议问题