Tuesday, February 25, 2020

#1 2007-01-15 09:49:14 am

mtorrance
Member
From:: Tulsa, OK
Registered: 2005-08-05
Posts: 125

Launch Remote Application via Remote Apple Events

Hi All,

I read in another post that a remote application must already be running to send it Apple Remote Events.

http://bbs.applescript.net/viewtopic.php?id=3727

However I have found that since the Finder is always running you can tell Finder to open the application. I wanted to launch an Automator App on my web server to run a perl script to update an index database.

Applescript:


   tell application "Finder" of machine "eppc://Username:Password@IP_Address"
       open file "Server HD:Applications:iTunes"
   end tell

When I run this iTunes launches on the other machine. I use it like.

Applescript:


   tell application "Finder" of machine "eppc://Username:Password@IP_Address"
       open file "Server HD:Users:admin:Documents:Rebuild IF Index-Quick"
   end tell

The last item "Rebuild IF Index-Quick" is the name of my Automator App.

Be sure Remote Apple Events is on for the remote computer.

Cheers,
MT


Filed under: Finder

Offline

 

#2 2007-01-15 04:00:36 pm

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11668
Website

Re: Launch Remote Application via Remote Apple Events

Hi MT,

you can check whether an application is running on the remote machine
and open it if necessary with this (e.g for iPhoto)

Applescript:

tell application "Finder" of machine "eppc://Username:Password@IP_Address"
   using terms from application "Finder"
       if "iPhoto" is not in (get name of every process) then
           open application file id "com.apple.iPhoto"
       end if
   end using terms from
end tell


regards

Stefan


Filed under: Finder

Offline

 

#3 2007-01-16 08:05:44 am

mtorrance
Member
From:: Tulsa, OK
Registered: 2005-08-05
Posts: 125

Re: Launch Remote Application via Remote Apple Events

I Like It! It will work even better for what I need to do. The Automator workflow I'm triggering on the remote machine can take 5-10 min to run so this approach will be aware of the apps status.

Question:
Are there other options to reference the application ? (e.g. "iPhoto")

Applescript:

open application file id "com.apple.iPhoto"

I need to trigger an Automator app named "Rebuild IF Index"

Thanks for the input.

MT

Last edited by mtorrance (2007-01-16 08:12:01 am)

Offline

 

#4 2007-01-16 08:36:29 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11668
Website

Re: Launch Remote Application via Remote Apple Events

Hi MT,

if your Automator workflow app is a "real" app, you can get the application file id with

Applescript:

get bundle identifier of (info for file "path:to:Rebuild IF Index")


regards

Stefan

Offline

 

#5 2007-01-20 11:39:49 am

mtorrance
Member
From:: Tulsa, OK
Registered: 2005-08-05
Posts: 125

Re: Launch Remote Application via Remote Apple Events

I'm getting an error on (get name of every process) the term "name" is highlighted

AppleScript Error
Finder got an error: can't find process on host. (-600)

It does this trying it with iPhoto as well as the app I'm trying to use it with.

Any Ideas?

Offline

 

#6 2007-01-20 03:22:30 pm

Eelco Houwink
Member
Registered: 2002-11-20
Posts: 317

Re: Launch Remote Application via Remote Apple Events

Mtorrance,

I don't see why you would burden Finder with a request that essentially is for "System Events".
Also, "using terms from" allows you to substitute the local app's AS dictionary to simplify compilation over the network (you're using it the other way around!)

So I'd suggest this:

Applescript:


using terms from application "System Events"
tell application "System Events" of machine "eppc://Username:Password@IP_Address"
set procNames to name of the processes
end tell
end using terms from


Eelco Houwink


Filed under: System

Offline

 

#7 2007-01-21 11:06:57 am

mtorrance
Member
From:: Tulsa, OK
Registered: 2005-08-05
Posts: 125

Re: Launch Remote Application via Remote Apple Events

Hello,

Good point about system events. I have switched to this on the local machine

Applescript:


tell application "System Events" of machine "eppc://User:Pass@IP_Address"
       open file "Server HD:Users:admin:Documents:Studio Scripts:Check Rebuild Status"
end tell

which triggers this on the remote machine

Applescript:


set isRunning to "false"
   
   tell application "System Events"
       set procNames to name of the processes
   end tell
   
   if (procNames contains "Rebuild IF Index-Quick") then
       set isRunning to "true"
   end if
   
   if (isRunning = "false") then
       tell application "System Events"
           open file "Server HD:Users:admin:Documents:Studio Scripts:Rebuild IF Index-Quick"
       end tell
   end if

I couldn't pull the process names from the remote machine so I just trigger the remote machine to check it's running processes and launch it if it is not running. Thanks for the input

MT


Filed under: System

Offline

 

#8 2007-01-21 11:16:14 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11668
Website

Re: Launch Remote Application via Remote Apple Events

mtorrance wrote:

Applescript:


set isRunning to "false"
   
   tell application "System Events"
       set procNames to name of the processes
   end tell
   
   if (procNames contains "Rebuild IF Index-Quick") then
       set isRunning to "true"
   end if
   
   if (isRunning = "false") then
       tell application "System Events"
           open file "Server HD:Users:admin:Documents:Studio Scripts:Rebuild IF Index-Quick"
       end tell
   end if


Hi,

this cannot work actually because you're addressing System Events of the localhost instead of the remote machine.
This should work

Applescript:

tell application "System Events" of machine "eppc://User:Pass@IP_Address"
   if ((get name of the processes) does not contain "Rebuild IF Index-Quick") then
       open file "Server HD:Users:admin:Documents:Studio Scripts:Rebuild IF Index-Quick"
   end if
end tell


regards

Stefan


Filed under: System

Offline

 

#9 2007-01-21 11:19:55 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11668
Website

Re: Launch Remote Application via Remote Apple Events

Eelco Houwink wrote:

Mtorrance,

I don't see why you would burden Finder with a request that essentially is for "System Events".


Hi Eelco,

although process is no property of the Finder's dictionary it works anyway


regards

Stefan

Offline

 

#10 2007-01-21 02:16:28 pm

Eelco Houwink
Member
Registered: 2002-11-20
Posts: 317

Re: Launch Remote Application via Remote Apple Events

Agree,
but Finder can be a busy little guy doing very little (especially with network scripting) so why use that as handover...


Eelco Houwink

Offline

 

#11 2007-01-24 03:09:31 pm

mtorrance
Member
From:: Tulsa, OK
Registered: 2005-08-05
Posts: 125

Re: Launch Remote Application via Remote Apple Events

Hi Stefan,

The below script

Applescript:

set isRunning to "false"

tell application "System Events"
set procNames to name of the processes
end tell

if (procNames contains "Rebuild IF Index-Quick") then
set isRunning to "true"
end if

if (isRunning = "false") then
tell application "System Events"
open file "Server HD:Users:admin:Documents:Studio Scripts:Rebuild IF Index-Quick"
end tell
end if

was running on the remote machine so it worked OK, it didn't need ( of machine "eppc://User:Pass@IP_Address" ) because the script is running on the machine that I needed to get the processes from, but I think I like your approach better as it doesn't require two scripts and is more effecient. I added it to the end of my Automator app and it works great!

Thanks A Bunch,
Mark


Filed under: System

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)