I'm posting this in the Sequoia forum because I believe the issue is related to security "features" in Sequoia.
Details: New Mac Mini (M4) running Sequoia 15.5 (all of the latest security updates installed). An AppleScript, running in Script Editor, that opens the Terminal app and sends 3 commands (keyboard entry) will sometimes run perfectly & other times will not run (due to keystrokes permission error). A standalone app made from the script will also sometimes work perfectly and other times not. The latest version of Python3 is installed on the Mini.
The standalone app is needed so I can make it a login item and run the script if there is a power failure and the Mac Mini reboots.
The script was working PERFECTLY (both in Script Editor and as a standalone app) on a previous Mac Mini (2014 Intel).
This is the script:
delay 30
tell application "Terminal"
activate
end tell
tell application "System Events"
keystroke "cd pigs"
key code 36
end tell
tell application "System Events"
keystroke "sudo python3 pigs.py"
key code 36
end tell
tell application "System Events"
keystroke "[Mini administrator password]"
key code 36
end tell
Again, sometimes this script works, other times it doesn’t. I cannot figure out any rhyme or reason nor any common situation that explains why it will sometimes run. It’s like a roll of the dice. Again, it worked PERFECTLY (for about 10 years) on my previous Mac Mini (older OS).
These are the errors that pop up when the script chokes. First, when it is run in the Script Editor and chokes:
This is when the standalone app version chokes:
Both apps have the necessary accessibility:
Right after it chokes, I can run it again and it might work (no error). Sometimes it works, sometimes it doesn’t. VERY weird! When it fails, it is failing at the very first keyboard command (“cd pigs”).
I spent about 40 minutes on the phone with Apple Support. I screen shared and they bumped me up to a higher level support rep twice. Final outcome: they had no idea what the problem might be.
The fact that the script sometimes works and sometimes not sure seems like an issue with the OS. Yet, nobody at Apple seems to care.
Any help or suggestions are much appreciated!
Mark
Details: New Mac Mini (M4) running Sequoia 15.5 (all of the latest security updates installed). An AppleScript, running in Script Editor, that opens the Terminal app and sends 3 commands (keyboard entry) will sometimes run perfectly & other times will not run (due to keystrokes permission error). A standalone app made from the script will also sometimes work perfectly and other times not. The latest version of Python3 is installed on the Mini.
The standalone app is needed so I can make it a login item and run the script if there is a power failure and the Mac Mini reboots.
The script was working PERFECTLY (both in Script Editor and as a standalone app) on a previous Mac Mini (2014 Intel).
This is the script:
delay 30
tell application "Terminal"
activate
end tell
tell application "System Events"
keystroke "cd pigs"
key code 36
end tell
tell application "System Events"
keystroke "sudo python3 pigs.py"
key code 36
end tell
tell application "System Events"
keystroke "[Mini administrator password]"
key code 36
end tell
- When launched, the script waits 30 seconds before opening Terminal. This is to allow the Mini time to fully reboot after a power failure.
- Script opens Terminal.
- Script changes Terminal’s command line to the “pigs” directory (folder). The pigs folder is in my user account directory.
- Script runs pigs.py (which is a python script).
- A sudo command requires the administrator’s password, the final step enters that password.
Again, sometimes this script works, other times it doesn’t. I cannot figure out any rhyme or reason nor any common situation that explains why it will sometimes run. It’s like a roll of the dice. Again, it worked PERFECTLY (for about 10 years) on my previous Mac Mini (older OS).
These are the errors that pop up when the script chokes. First, when it is run in the Script Editor and chokes:

This is when the standalone app version chokes:

Both apps have the necessary accessibility:

Right after it chokes, I can run it again and it might work (no error). Sometimes it works, sometimes it doesn’t. VERY weird! When it fails, it is failing at the very first keyboard command (“cd pigs”).
I spent about 40 minutes on the phone with Apple Support. I screen shared and they bumped me up to a higher level support rep twice. Final outcome: they had no idea what the problem might be.
The fact that the script sometimes works and sometimes not sure seems like an issue with the OS. Yet, nobody at Apple seems to care.
Any help or suggestions are much appreciated!
Mark