Accessing Remote Machine

Posted on
Tue Nov 02, 2010 10:24 am
pacman offline
Posts: 67
Joined: Sep 17, 2008
Location: Pacifica, CA

Accessing Remote Machine

Does anyone know how to check if a remote machine referenced in an AppleScript is available before sending a command to the machine? I have a trigger action that calls for a remote machine to say "TEXT" but if the machine is asleep of off then the IndigoServer gets hung on the AS command until I activate the remote machine referenced. I want to avoid the hang. I tried using "try" blocks but no joy.

set _Remote to "eppc://David:XXXXXX@192.168.0.199"
try
    tell application "Finder" of machine _Remote
        
        say "alert, family room"
        
    end tell
end try

Posted on
Tue Nov 02, 2010 11:03 am
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Accessing Remote Machine

It's best to not run that script embedded, just for the reason you said - it has the potential to hang up the IndigoServer process, which usually isn't what you want to happen. "try" and "with timeout" don't seem to apply to a remote tell, so you have to do something else.

Here's one way you can check to make sure the machine is there before trying the remote tell, which should make the script more safe for running embedded:

Code: Select all
set _Remote to "eppc://David:XXXXXX@192.168.0.199"
try
   do shell script "ping -c 1 -t 3 192.168.1.5"
   tell application "Finder" of machine _Remote
      say "alert, family room"
   end tell
on error number errNum
   log "Remote machine is offline"
end try


This will wait 3 seconds to see if the machine returns successfully from a ping - 3 seconds is generous for a machine on a local network but you can adjust it (change the 3 to something else) if you're willing to wait longer. If it responds the script continues, if not, it logs something to the Indigo event log.

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Nov 02, 2010 1:27 pm
pacman offline
Posts: 67
Joined: Sep 17, 2008
Location: Pacifica, CA

Re: Accessing Remote Machine

Embedding your suggestion brings same results. I wonder if it would be the same if I saved the script for reference within IndigoServer. I'll play some more. I may need to run a script from my target machine to change a variable when closing down or going to sleep.

Posted on
Tue Nov 02, 2010 2:28 pm
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Accessing Remote Machine

If it's answering the ping but the timing out, then it's some other problem - the "Finder" isn't able to respond to the apple event for some reason. I'd say the target machine is having an issue of some sort - perhaps network?

Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Tue Nov 02, 2010 8:51 pm
berkinet offline
User avatar
Posts: 3290
Joined: Nov 18, 2008
Location: Berkeley, CA, USA & Mougins, France

Re: Accessing Remote Machine

It sounds like the Mac is answering the ping without actually waking up. IF that is the case, you might take a look at Wake on Demand. I do not have personal experience with this service, and you may not have the right equipment on your network. But, it seems like it might be worth a look.

Posted on
Sat Aug 03, 2013 10:44 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Accessing Remote Machine

[EDIT]
I guess this is the privilege violation error discussed in other sections. Any suggestion how to "say" something on another MAC?
[Edit end]

when executing this apple script (have reduced it to the minimum & replaced uid and password with yyy xxx):

tell application "Finder" of machine "eppc://yyy:xxx@mini.local"
say "hello"
end tell

I get in events / replies in the applescript editor when I run the script:

tell application "Finder" of machine "eppc://mini.local"
say " hello"
--> error number -10004
end tell

and no hello on "mini"


I can login, have screen sharing open etc on mini
enabled file sharing/ screen sharing/ remote login/ apple remote events ....
with fire wall on and off on "mini"
also tried with IP number instead of "mini.local"

any suggestions?


thx

Karl

Posted on
Sun Aug 04, 2013 10:36 am
jay (support) offline
Site Admin
User avatar
Posts: 18224
Joined: Mar 19, 2008
Location: Austin, Texas

Re: Accessing Remote Machine


Jay (Indigo Support)
Twitter | Facebook | LinkedIn

Posted on
Sun Aug 04, 2013 9:19 pm
kw123 offline
User avatar
Posts: 8366
Joined: May 12, 2013
Location: Dallas, TX

Re: Accessing Remote Machine

I am using a work around:
1. on the indigo MAC have a script create a text file with the text string that should be "read" (SAY), do a "cp source target" *)
2. on the target MAC have an apple script running that checks for the file and if file exists read file and do a "say" with the text. Then delete the file.

if anyone is interested I could post some details.

thx

Karl

*) requires a mount and sharing setup between Indigo MAC and target MAC

Page 1 of 1

Who is online

Users browsing this forum: No registered users and 21 guests