As part of a BASH-script I need to launch some python-code with an input-parameter. I also want to avoid creating an temporary *.py-files.
This is what I have so far:
input=123
output=$(
python - <<'END_SCRIPT'
print("$input")
END_SCRIPT
)
echo $output
This snippet writes the output of the python-call into an output-variable. But instead of returning "123" it returns "$input", because the variable with not be interpreted during the piping into python. Is there any way to forward the input variable as a parameter to python while reading from StdIn?