Applescript and Apple Remote Events

I’d like to send a notification from an Apple OS X Server to my laptop using Apple Remote Events.

Some example code that I found online suggested that something like this might work:


tell application "System Events" of machine "eppc://172.16.1.1"
	tell process "Notification Center"
		display notification "Foo"
	end tell
end tell

but it gives me this error:

Syntax Error
Application isn’t running.

I have enabled Apple Remote Events on my laptop, and provided a valid password.

Any suggestions? Should this be possible?

Thank you.

There is a known “bug” with remote event and the application system events. IIRC StefanK once posted a clever solution to launch system events (which I’m using on one of my servers; scripting addition commands are executed by systems events on a remote machine).

-- code is written on a non-mac so it's not tested
set theMachine to "eppc://172.16.1.1"
using terms from application "Finder"
tell application "Finder" of machine theMachine
get every process -- this will launch "System Events" if it is not running
end tell
end using terms

using terms from application "System Events"
tell application "System Events" of machine theMachine
   tell process "Notification Center"
       display notification "Foo"
   end tell
end tell
end using terms

p.s. if it still doesn’t work, since Yosemite Apple has made a terrible update according to remote application names. You have to target them by their localized name and no longer to their real application name. System Events has to be targeted on the remote as Systeem-Events on a Dutch machine for instance.

Thanks for the reply!

And I think that I understand the issue and what we need to do.

I wasn’t able to make the script work, however. Both the original and my slightly modified version - using “end using terms from” rather than “end using terms” - gave this error:

Expected “”" but found end of script.

This is the script that I am using:


set theMachine to "eppc://172.16.1.1"

using terms from application "Finder"
	tell application "Finder" of machine theMachine
		get every process
	end tell
end using terms from

using terms from application "System Events"
	tell application "System Events" of machine theMachine
		tell process "Notification Center"
			display notification "Foo"
		end tell
	end tell
end using terms from

It seems that AppleScript doesn’t like the “of machine theMachine” clause in this script.


tell application "System Events" of machine theMachine
	tell process "Notification Center"
		display notification "Foo"
	end tell
end tell

This works fine.


tell application "System Events"
	tell process "Notification Center"
		display notification "Foo"
	end tell
end tell

although it shows the notification on the local machine, of course.

But the version with the “…of machine theMachine” gives a syntax error.

Am I missing something that should be obvious?

First of all sorry for the wrong end using terms from lines, I wasn’t behind a machine with an script editor right then but just showing the procedures on how to launch system events. For you other problem I assume you have an non-English machine? When using remote apple events you need to target the remote application by it’s localized name and not it’s actual name like you would targeting applications locally. On my machine to target System Events locally I use “System Events” no matter what the language of the OS is, but remotely I need to target it as “Systeem-Events” (Dutch).

set theMachine to "eppc://xxx.xxx.xxx.xxx"
using terms from application "Finder"
	tell application "Finder" of machine theMachine
		get processes
	end tell
end using terms from

using terms from application "System Events"
	-- localized name for System Events
	set localizedAppName to "Systeem-Events"
	tell application localizedAppName of machine theMachine
		display notification "Hello World!" with title "Foo"
	end tell
end using terms from

– Just fixed some misspellings, this should work as is once you replace IP address
– The remote machine requires Remote Apple Events be ON
– You will have to enter a user name and password that is available
– in the Sharing > Remote Apple Events dialog box on the remote machine

use AppleScript version “2.4” – Yosemite (10.10) or later
use scripting additions

set RemoteMac to “eppc://XXX.XXX.XXX.XXX”
using terms from application “Finder”
tell application “Finder” of machine RemoteMac
get processes
end tell
end using terms from

using terms from application “System Events”
– localized name for System Events
set localizedAppName to “System Events”
tell application localizedAppName of machine RemoteMac
display notification “Hello World!” with title “TEST”
end tell
end using terms from