Dark Launch

This is a Dark Launch.

How to Include Python Script in Bash Script

To run a multiline python script in a bash shell script from the commandline, do the following

cat <<EOF | python -
import sys
from pprint import pprint
pprint(sys.path)
EOF

This will allow running python code inside a self-contained bash script.

Comments


  1. Alternatively, something like this works as well:
    eval python - << EOF
    import sys
    from pprint import pprint
    pprint(sys.path)
    EOF