Skip to content

Instantly share code, notes, and snippets.

@krackers
Forked from DarwinAwardWinner/python-bash-wrapper.py
Created January 26, 2020 04:24
Show Gist options
  • Select an option

  • Save krackers/f96f23c8a1eca1fbeb0dfb95383752af to your computer and use it in GitHub Desktop.

Select an option

Save krackers/f96f23c8a1eca1fbeb0dfb95383752af to your computer and use it in GitHub Desktop.
Put bash cluster setup code and python script in a single file
#!/bin/bash
# -*- mode:python -*-
#PBS -l nodes=1:ppn=8,mem=30gb
''''/bin/true
# This is bash code to set up the environment
echo "Hello from bash!"
echo "Args are: $@"
# Bash setup code ends here
python - "$@" <<EOF
''' # Python starts here '''
print "Hello from Python!"
import sys
print "Args are:", sys.argv[1:]
# End Python code
EOF = None
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment