I have a shell script with the below content
$cat sample.sh
export greet="hello"
echo $greet
I have a python script where I want to call the bash script and use the exported environment variable.
$cat try.py
import os
os.system(". /tmp/sample.sh")
print("Greet from python : "+os.environ['greet'])
The above script doesn't retrieve the environment variable 'greet'. Also tried using subprocess, but the env variable is not available in python. Looks like its shell context related. https://www.shell-tips.com/bash/source-dot-command/ Any ideas?