Restarting Applications on remote machines

Hi everybody -
OK, so, I need a way to remotely restart an app that is not itself Apple Script friendly.
I think I have the eppc:// part right, but I’m getting ‘type’ errors when I run this.
I’m also not sure how to specify the app when I want to re-open it - I’m guessing that I can all it by name if it is running, but how to launch it?


set remMachine to "eppc://user:pass@192.168.41.66"

tell application "FORK Media Player Pro 01" of remMachine to quit

tell application "Finder" of remMachine to open "/Applications/Fork Automation/Fork Production/Fork MediaPlayer/MPR 01/FORK Media Player Pro 01"

Thanks so much!
Chris

Hi and welcome :slight_smile:

A reliable way to launch remote applications is (in this example for iPhoto)


tell application "Finder" of machine RemMachine
	using terms from application "Finder"
		if "iPhoto" is not in (get name of processes) then open application file id "com.apple.iPhoto"
	end using terms from
end tell

you need the name of the process of your application and the bundle identifier

Thanks Stephan -
OK, so, this app (FORK Media Player Pro.app) doen’t have anything in the prefs - we generate no com.fork.MediaPlayer plist or anything…
is that required to launch a file???
Is there anyway I can just use the path?

Chris

bundle identifier is a property of an application process,
and (application) process is an element of application “System Events”.

You can get the bundle identifier of your app with


get bundle identifier of (info for (choose file))

In the open dialog choose the application

alwasy s close, yet so far…

OK, so Bundle ID - I ran that script, selected the app, which then opened, but I did not see any value returned. Same thing w/ OS X Chess app.
What should I expect to see?

Second question (again, thanks for your help here) -
I’m currently trying this one:


set remMachine to "eppc://user:pass@192.168.41.66"
set FORKMPR to "Macintosh HD:Applications:Fork Automation:Fork Production:Fork MediaPlayer:MPR 01:Fork Media Player Pro 01.app"

tell application "Finder" of machine remMachine
	using terms from application "Finder"
		quit FORKMPR
	end using terms from
end tell

tell application "Finder" of machine remMachine
	using terms from application "Finder"
		open FORKMPR
	end using terms from
end tell


and it is timing out, which at least seems better…
Apple Remote Events is def on.
Is there a log I can check to see if the event is getting thru? I dont’ see anything in Console or System.

This script

 set remMachine to "eppc://user:pass@192.168.41.66"

tell application 
"Finder" of machine remMachine
	
	activate
end tell

fails to compile w/ an error:
Can’t get “Finder” of machine remMachine. Access not allowed.

Is there a good way to test if the eppc:// is resolving?

Chris

OK, I continue to get closer here…
I tried running the previosu script, and this one:


set remMachine to "eppc://user:pass@192.168.41.66"
set FORKMPR to "Macintosh HD:Applications:Fork Automation:Fork Production:Fork MediaPlayer:MPR 01:Fork Media Player Pro 01.app"

tell application "Fork Media Player Pro.app" of machine remMachine to quit

tell application FORKMPR of machine remMachine
	
	activate
end tell

From a box on the same subnet, and got the error:
Fork Media Player Pro got an error: Cannot find process on host

I guess this means I can’t simpl refer to it by name, right?

CK

Talking to remote apps is quite tricky.

You cannot launch an application directly which is currently not running.
The only application which is always running is the Finder, so you must use the Finder to launch other apps.

What kind of result do you expect? The result is, the requested application launches on the remote machine.
To avoid timing problems add a repeat loop which continues if the application appears in the list of processes.
From the iPhoto example above


tell application "Finder" of machine RemMachine
	using terms from application "Finder"
		if "iPhoto" is not in (get name of processes) then open application file id "com.apple.iPhoto"
		repeat until "iPhoto" is in (get name of every process)
			delay 1
		end repeat
	end using terms from
end tell