help-make
[Top][All Lists]
Advanced

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

RE: Output of one recipe in arguments to subsequent recipes?


From: Cook, Malcolm
Subject: RE: Output of one recipe in arguments to subsequent recipes?
Date: Thu, 29 Aug 2013 23:48:19 +0000

by default, each of your three recipe lines is running in its own subshell.

thus the export in first line is not seen by subsequent lines.

if you end each command with a semi-colon and a backslash followed by your 
neline, then the three commands will execute in the same subshell.

see:
http://www.gnu.org/software/make/manual/html_node/Execution.html
and
http://www.gnu.org/software/make/manual/html_node/Splitting-Lines.html#Splitting-Lines

you might prefer an "&&" instead of a ";" if you want to stop execution after 
the first command that fails.


~ address@hidden

________________________________________
From: address@hidden address@hidden on behalf of Jack Bates address@hidden
Sent: Thursday, August 29, 2013 10:34 AM
To: address@hidden
Subject: Output of one recipe in arguments to subsequent recipes?

Is there any way to use the standard output of one command (recipe) in
arguments to subsequent recipes? How would you approach something like
the following (which doesn't work):

 > school:
 >   export HOST=$$(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 want to assign the standard output to the HOST variable and then use
that in arguments to subsequent commands. I guess the above doesn't work
because variables from one recipe aren't propagated to subsequent
recipes, but is there any way to do it correctly?

Thanks!

_______________________________________________
Help-make mailing list
address@hidden
https://lists.gnu.org/mailman/listinfo/help-make



reply via email to

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