Bash shell script (test.sh)
#!/bin/bash echo "Executing a bash statement" export bashvar=100 cat << EOF > pyscript.py #!/usr/bin/python import subprocess print 'Hello python' subprocess.call(["echo", "$bashvar"]) EOF chmod 755 pyscript.py python ./pyscript.py rm ./pyscript.py
Result
$ ./test.sh Executing a bash statement Hello python 100 $