Issue
I have the shell script where I create a Python file on the fly:
#!/bin/bash
args=("$@")
GIT_PASSWORD=${args[0]}
export $GIT_PASSWORD
python - << EOF
import os
print(os.environ.get("GIT_PASSWORD"))
EOF
echo $GIT_PASSWORD
echo "Back to bash"
I want to be able to access the variable GIT_PASSWORD
, but unfortunately, I am not able to pass it to the python file.
Does anyone know what I am doing wrong and how I may fix that?
Solution
The thing is that you're not actually setting an env variable, you need to change the export:
export GIT_PASSWORD=$GIT_PASSWORD
please do read the comment interaction below
Answered By - Edo Akse Answer Checked By - Senaida (WPSolving Volunteer)