I'm trying to transfer a variable in a bash-script to an embedded python-function. A minimal example of the script I'm using is given below:
#!/bin/bash
function python_print() {
PYTHON_ARG="$1" python - <<END
import os
p = str(os.environ['PYTHON_ARG'])
print('The Variable is ' + p)
END
}
DIRIN=$1
FULLPATH=$ realpath $OUTFILE
python_print $FULLPATH
Running the script gives me: "The variable is "; so it seems the argument FULLPATH is not transfered to the function. The strange thing is, the code works if "$FULLPATH" is replaced either with "$1", "$DIRIN" or any hardcoded string. Where is my mistake? I'm grateful for any advice!
OUTFILEever defined?python_print $FULLPATHyou didecho $FULLPATHdoes it print the value you expect? I suspect the line above is meant to beFULLPATH=$(realpath $OUTFILE)