[ILUG] Logging and displaying output of shell commands
Brian Foster
blf at utvinternet.ie
Tue Oct 7 20:16:30 IST 2008
this seems to have gone missing from my posting... ;-\
a slightly different trick, analogous to having the
user type:
make some_rule 2>&1 | tee -a FILE
is to do that within the Makefile, something like:
some_rule:
ifeq($(strip $V),2)
$(MAKE) V=1 $@ 2>&1 | tee -a my_log.log
else
some_cmd
endif
or variations on the idea, such as:
ifeq($(strip $V),2)
rule1 rule2 rule3 ... ruleN:
$(MAKE) V=1 $@ 2>&1 | tee -a my_log.log
else
rule1:
cmd1 ...
rule2:
cmd2 ...
rule3:
cmd3 ...
...
ruleN:
cmdN ...
endif
not tested, and I probably really do have the syntax
messed up now. of course, you'd still probably want
to do one of the previously-posted tricks (i.e., use
`pipefail', `PIPESTATUS', &tc) for the V = 2 case of
`$(MAKE) V=1 ...' so the sub-`make's exit(2)-status
isn't lost.
cheers!
-blf-
--
“How many surrealists does it take to | Brian Foster
change a lightbulb? Three. One calms | somewhere in south of France
the warthog, and two fill the bathtub | Stop E$$o (ExxonMobil)!
with brightly-coloured machine tools.” | http://www.stopesso.com
More information about the ILUG
mailing list