import subprocess print("""#!/bin/bash cat <<- "EOF" >> .lock """) print(subprocess.check_output(["python", "scripts/prepare_py.py"]).decode()) print(""" EOF /usr/bin/env python .lock rm .lock """)