1

I have this problem with makefile. When I execute this command :

kill $(ps aux | grep '[p]ython service/logdata.py' | awk '{print $2}')

from terminal it works fine. But with this rule from makefile :

stop:
    kill $(ps aux | grep '[p]ython service/logdata.py' | awk '{print $2}')

I get this error:

kill 

Usage:
 kill [options] <pid> [...]

Options:
 <pid> [...]            send signal to every <pid> listed
 -<signal>, -s, --signal <signal>
                        specify the <signal> to be sent
 -l, --list=[<signal>]  list all signal names, or convert one to a name
 -L, --table            list all signal names in a nice table

 -h, --help     display this help and exit
 -V, --version  output version information and exit

For more details see kill(1).
makefile:19: recipe for target 'stop' failed
make: *** [stop] Error 1

I already checked that grep output is not empty.

Thank you in advance.

Omar HAYAK
  • 13
  • 5

1 Answers1

4

$ has special meaning in makefiles, you need to double it to pass it literally to the shell.

stop:
    kill $$(ps aux | grep '[p]ython service/logdata.py' | awk '{print $$2}')
Barmar
  • 741,623
  • 53
  • 500
  • 612
  • thank you for your help. I thought that pure shell commands are passed literally. – Omar HAYAK Feb 20 '17 at 09:44
  • Why would you think that? Haven't you seen commands like `$(CC) $<` in the makefile? That's parsing the `$` in the makefile. – Barmar Feb 20 '17 at 10:23