0

I am trying to run a shell script file using cron and I am getting permission denied error.

Here is my cron file.

53 14 30 10 * $HOME/Documents/Python/shellScript.sh

I want to run shellScript file at a particular time today.

Here is my shellScript.sh file.

osascript<<EOF
tell application "System Events"
  tell process "Terminal" to keystroke "t" using command down
end
tell application "Terminal"
  activate
  do script with command "python file1.py" in window 1
end tell
EOF

osascript<<EOF
tell application "System Events"
  tell process "Terminal" to keystroke "t" using command down
end
tell application "Terminal"
  activate
  do script with command "./ngrok 5000" in window 1
end tell
EOF

python file2.py

I am getting this in the mail. /bin/sh: /Users/XXX/Documents/Python/shellScript.sh: Permission denied

It would be great if anyone can help me with this. Thank you

user3745870
  • 321
  • 1
  • 5
  • 13

2 Answers2

7

you must give execute permission to your script before executing.

chmod u+x shellScript.sh
Hackaholic
  • 19,069
  • 5
  • 54
  • 72
0

Not sure why you are invoking osascript and a Terminal at all - OSX's crond is perfectly able to run scripts itself.

You should be able to just do this:

#!/bin/bash
python /path/to/file1.py &
ngrok 5000 &
python /path/to/file2.py

and be sure to make the above executable with

chmod +x /full/path/to/shellScript.sh
Mark Setchell
  • 191,897
  • 31
  • 273
  • 432