Applescript
You can execute shell commands directly from Applescript
do shell script "ssh user@linuxbox command-to-run"
Automator
You can create a new workflow and insert the necessary shell commands into the "Execute shell script" action.
A simple fix is to save the script as a text file instead.
At the top of the script add the osascript
shebang
#!/usr/bin/osascript
example:
#!/usr/bin/osascript
say "hello"
tell application "Safari" to activate
tell application "System Events"
delay 2
keystroke "p" using command down
tell application process "Safari"
tell application "System Events"
tell process "Safari"
click menu button "PDF" of sheet 1 of window 1
delay 1
click menu item "Save PDF to Web Receipts Folder" of menu of menu button "PDF" of sheet 1 of window 1
end tell
end tell
end tell
end tell
The in the save dialog choose Text as the file format.
The file will be saved as plain text but with the .applescript
extension.
In terminal make the save script text file executable.
I used:
chmod +x /Users/UserName/Scripts/newTest1.applescript
In the command arguments of the LaunchAgent just add the path to the file.
Do not add the osascript command to the arguments. You do not need it.
The saved script text file will act like an executable shell script.
When you first load or run the LaunchAgents you will get a prompt to set the Assistive Access in System Preferences. If you already have System preferences open you will not but the Script text file will be added to the list.
You now just have to check its check box to allow it.
I would reload the LaunchAgent so it picks up straight away.
I have double checked this with the script above and all works as expected.
Best Answer
"Is there a workaround?" I'd call it the "right" way.
Use the script editor. save the script as an application. Thus, the script becomes a full fledged application. Give the app assertive capabilities. should you want to start the app from the terminal, open your-app.
What to worry about: "Effective defenses against malware and other threats" by John Galt https://discussions.apple.com/docs/DOC-8841