Alex Rivera | Logout

start-stop-daemon quoted arguments misinterpreted

Asked 2009-11-02T13:04:00.207
24

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 I can't get the quotations to filter down correctly.

I'll use ls here so we don't have to look at binaries and arguments that most people wont know or care about.

The end result I am looking for is for start-stop... to run ls -la "/folder with space/"

DAEMON=/usr/bin/ls 
DAEMON_OPTS='-la "/folder with space/"'

start-stop-daemon --start --make-pidfile --pidfile $PID --exec $DAEMON -- $DAEMON_OPTS

Double escaping the options and trying innumerable variations of quotations do not help... Then they end up at the daemon they are always messed up. Enclosing $DAEMON_OPTS in quotes changes things... then they are seen as one since quote... never the right number though :)

Echoing the command-line (start-stop...) prints exactly the right stuff to screen. But the daemon (the real one, not ls) complains about the wrong number of arguments.

How do I specify a variable so that quotes inside it are brought along to the daemon correctly?

Edit
Report

1 Answer

0

Have you tried doing it the other way around with the quotes? Like this:

DAEMON_OPTS='-la "/folder with space/"'

I'm not sure, but that might work?

(I would have posted this as a comment to the previous answer, if only I had had enough reputation to do so).

answered 2009-11-02T14:32:07.487

Your Answer