pythonbashshellmakefilegnu-make

How to pass shell variable returned from pythonscript into another shell to run another pythonscript in Makefile rule?


I am trying for several hours and researched how to pass a shell variable which is returned from a pythonscript into another shellscript to run another pythonscript.

I have an example below:

MyRule:
export VAR=$(shell python.exe mySkript1.py someInputs); \
echo $$VAR; \
$(shell python.exe mySkript2.py someInputs2 $VAR}) \
echo $$VAR;

How can I pass the variable VAR into the second shell line?

I tried the following but none of them made it:

"$VAR"
$$VAR
$(VAR)

.


Solution

  • There is no Makefile variable $VAR so it gets replaced with the empty string.

    Anyway, don't use $(shell ...) inside recipes.

    MyRule:
        export VAR=$$(python.exe mySkript1.py someInputs); \
        echo $$VAR; \
        python.exe mySkript2.py someInputs2 "$$VAR"; \
        echo "$$VAR"