Using python on Mac OS, I would like to open a file for writing and put some shell commands into it. Later to be run in terminal.
with open("my_script.sh", "w") as fd:
fd.write("#!/bin/sh\n")
fd.write("echo $PATH\n")
This will create the file, but I could not figure how to set the execute bit so when I run it in the Terminal I will not get:
sh: my_script.sh: Permission denied
Pick the value properly though. Some values might not be safe.