Skip to content

Instantly share code, notes, and snippets.

@shadowbq
Created January 31, 2023 00:32
Show Gist options
  • Save shadowbq/8373149c12078dc8cf93b836022bb612 to your computer and use it in GitHub Desktop.
Save shadowbq/8373149c12078dc8cf93b836022bb612 to your computer and use it in GitHub Desktop.
Python in Bash for script delivery
#!/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