help-make
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Output of on "recipe" in arguments of subsequent recipes?


From: Jack Bates
Subject: Output of on "recipe" in arguments of subsequent recipes?
Date: Sat, 24 Mar 2012 11:08:28 -0700
User-agent: Mozilla/5.0 (X11; Linux i686; rv:10.0.2) Gecko/20120216 Thunderbird/10.0.2

I am struggling to use the standard output of one make "recipe" in arguments of subsequent recipes, e.g. something like:

school:
  HOST=$(shell php /usr/share/cacti/cli/add_device.php \
    --description=school \
    --ip=172.23.0.1 \
    --template=1 | sed -n 's/Success - new device-id: (\([0-9]\+\))/\1/p')

  php /usr/share/cacti/cli/add_tree.php \
    --type=node \
    --node-type=host \
    --tree-id=$(DEFAULT_TREE) \
    --host-id=$(HOST)

  php /usr/share/cacti/cli/add_graphs.php \
    --graph-type=ds \
    --graph-template-id=$(TRAFFIC) \
    --host-id=$(HOST) \
    --snmp-query-id=$(INTERFACE_STATISTICS) \
    --snmp-query-type-id=$(IN_OUT_BITS) \
    --snmp-field=ifOperStatus \
    --snmp-value=Up

I intend to assign the standard output to a variable ("HOST") then use this variable in arguments of subsequent recipes. I have some idea why this fails: "HOST=..." is evaluated by the shell, not by Make. How to do it correctly?

Also Make normally fails when a recipe exits with nonzero status. I want this behavior, but the $(shell ...) function prevents it?

Thanks for any advice!



reply via email to

[Prev in Thread] Current Thread [Next in Thread]