Hi,
I guess that shell scripts doesn’t work at all on remote machines (for security reasons).
Talking to a remote machine with AppleScript is based on Remote Apple Events
and shell scripts don’t send Apple Events
A way to run a script on a remote machine is to save is as application
and run it with for example
tell app "Finder" of machine remoteMachine to open application file "test.app" of desktop
unlike local machines, a tell block doesn’t launch the target application automatically on a remote machine.
You have to launch the application explicitly by opening the application file id with the Finder.
because the Finder is the only application, which is always running
Here is an alternative solution which does NOT require AppleScript Runner:
tell application "Finder" of machine "eppc://user:pass@MachineB.local"
set s to load script "/Users/user/Desktop/someScript.scpt"
run script s
end tell
Another option that works well for me, is to go to ‘Preferences’ in your Mail app. and set up a rule to run a script based on what’s written in the Subject line of an incoming email.
Thank you. I tested with a simple script that just pops up a Display Dialog, but the dialog appeared on my local machine, not the remote machine where I need to send the command to launch the script. This surprised me.
I tried your suggestion as it sounds perfect but I get this error:
Can’t get application (application file “test.app” of folder “Desktop” of folder “jessie” of folder “Users” of startup disk of application “Finder” of machine “eppc://user:pass@machineb.local”) of desktop.
“test.app” is there on the Desktop exactly where the error says it is.
try this, I’ve tested it with a different user on the same machine.
It checks if the user is present.
In this case the name of the application and the UID is included in the eppc string
property user_name : "myuser" -- admin username
property pass_word : "mypass" -- admin password
property uid : "502" -- user id of remote user
set host_name to host name of (system info)
set s to "eppc://" & user_name & ":" & pass_word & "@" & host_name & "/Finder?uid=" & uid
if check_user(s) then
using terms from application "Finder"
tell application s to open application file "test.app"
end using terms from
end if
on check_user(eppc)
using terms from application "Finder"
try
tell application eppc to get (desktop as string)
return true
on error
return false
end try
end using terms from
end check_user