Just a tip: When issuing the runuser command I usually use the -c
option, and I always use double quotes instead of single quotes around
the command to be ran. This allows me to use single quotes within the
double-quoted command to pass a quoted argument.
For example, the following will not work because of nested single quotes:
runuser -l fred -c 'find /foo/foobar -name '*.txt''
(two single quotes at the end of the line)
This example uses double quotes and it works fine:
runuser -l fred -c "find /foo/foobar -name '*.txt'"
(a double-quote before "find", single quotes around '*.txt' and a double quote at the end of the line)
If
you want to know WHY this works, the shell processes command lines with
double quotes twice. The first pass lets the interpreter know that
anything within double quotes is an argument and that any single quotes
within the double qutes are to be taken literally.
Inga kommentarer:
Skicka en kommentar