Created
January 31, 2023 00:32
-
-
Save shadowbq/8373149c12078dc8cf93b836022bb612 to your computer and use it in GitHub Desktop.
Python in Bash for script delivery
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
set -a | |
command -v python3 >/dev/null 2>&1 || { | |
echo >&2 "Python3 required. Aborting." | |
exit 1 | |
} | |
MYSTRING="Do something in bash" | |
export $MYSTRING | |
python3 - <<EOF | |
import os | |
pyShellString = os.environ['MYSTRING'] | |
myPyString = "Printing python var" | |
print(myPyString) | |
print("print from os.env: ", pyShellString) | |
EOF | |
set +a | |
echo "Back to bash" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment