Display Dialog / Alert on remote machine

I know you can control applications on a remote computer with something along these lines:

-- Make sure "Remote Apple Events" is checked in Sharing Prefernces on remote machine
-- Run this on remote machine to populate eppc command
set remotePswd to "password"
set {shortUser, hostName} to {short user name, host name} of (system info)
set remoteMachine to "eppc://" & shortUser & ":" & remotePswd & "@" & hostName
-- Run this on local machine to control remote machine
set remoteFinder to application "Finder" of machine "eppc://user:password@host" -- output of first script
using terms from application "Finder"
	tell remoteFinder
		open application file id "com.apple.TextEdit"
	end tell
end using terms from

Any thoughts on the best way of using (display dialog) on the remote machine? Preferably, I would like to be able to access the response from the dialog as well.

tell application "Finder" of machine "eppc://user:password@host" -- output of first script
	display dialog "hi"
end tell

→ error “Finder got an error: A privilege violation occurred.” number -10004

I believe Scripting Addition Security in the release notes discusses the issue but I have not been able to resolve it yet.
https://developer.apple.com/library/mac/#releasenotes/AppleScript/RN-AppleScript/RN-10_6/RN-10_6.html

You will need to have a script application on the remote machine that shows the dialog (and returns the response). Then you call the relevant handler of the script.

Thanks Shane,

What I am trying to do is to provide updates to a user on a remote machine on the status of an event occurring on my local machine. Let me chew on your solution for a while.

Shane, is what you are suggesting?

So if I have this saved as an application (remote_handler.app) on my local computer

on run
	say "run"
end run

on displayD(yourMessage)
	display dialog yourMessage buttons "Cancel"
end displayD

I would call the handler like this:


set myScript to load script file "path:to:my:remote_handler.app:"

tell myScript
	displayD("Hi") --subroutine in the loaded script, in case you don't want the whole script to run.
end tell

How would I do this when then the remote_handler.app is saved on the remote computer?

You can Growl to a remote machine (that has Growl installed). I’ve not done it, but here are some instructions

Thanks for the Growl tip. However, I need to incorporate the remote user’s input.

Can’t he growl back?

I would like to keep the functionality of display dialog.

Not quite – you don’t want to load the remote script, you want to run it.

The application “dispD.app” is saved on the remote machine and should accept the yourMessage parameter.


on run {yourMessage}
	display dialog yourMessage buttons {"A", "B"}
end run

I run this script from the local computer:

using terms from application "Finder"
	set remoteFinder to application "Finder" of machine "eppc://user:password@host"
	tell remoteFinder to run script file "path:to:my:dispD.app" with parameters {"Hi!"}
end using terms from

and get this response:

I mean run it like you would run any other app – use the open command.

I can launch the application remotely but I don’t get the user response and I can’t pass any parameters to it.

What I meant was a remote app with a handler like:

on doIt(aMessage)
display dialog aMessage buttons {"One", "Two", "Three"}
return button returned of result
end doIt

And then calling it like this:

tell application "My test" of machine "eppc://PB.local"
	doIt("Hello world")
end tell

I believe that worked at one stage, but my tests suggest it doesn’t any more – it returns “No user interaction allowed. (-1703)”.

So I think you’re out of luck…

Either way, Thanks for all of the help !