Check your script again. There should be
two backquotes (
`
) around the
which
command. Backquotes denote a sub-shell command, the output of which is inserted into the invoking command. In your case
which hcitool
probably returns
/usr/bin/hcitool, so
setcap 'cap_net_admin' `which hcitool`
is equivalent to
setcap 'cap_net_admin' /usr/bin/hcitool
Note that if you're using bash, then sub-shells are more often called using the
$( )
usage rather than the backquotes. There are a few reasons for this. Firstly, depending on the font used, backqoutes and single quotes can be hard to distinguish, leading to scripting errors. They're also quite small and easy to miss when reading an example. But mostly, the
$( )
usage can be nested, whereas backquotes cannot. This means that with
$( )
you can do
$ cmd1 c1arg1 $(cmd2 $(cmd3 c3arg1 c3arg2) c2arg1 c2arg2) c1arg2
If you were to try this with backquotes you get the following:
$ cmd1 c1arg1 `cmd2 `cmd3 c3arg1 c3arg2 `c2arg1 c2arg2` c1arg2
In this case,
cmd2
gets called in a sub-shell with no arguments, we try to create a sub-shell with the command
c2arg1
(which probably fails).