connection to remote machine in ASOC projects

Hello everyone,
I am currently creating a new ASOC project in Xcode. I have created a few projects using Shane Stanley’s excellent book as a resource. Kudos to Shane.

To my question, I am in the process of writing my first ASOC project which includes remote apple events to control Excel on a remote computer. Shane does have some information about controlling applications on the remote machine, but not to make the connection to the machine itself. I am curious if anyone can help with the syntax i need to use to make the connection.

Going back to the AppleScript Studio days, you could use a connection such as this, then control the application


set theRemoteMac to "eppc://username:password@ip_address"

tell application "Excel" of machine theRemoteMac
		using terms from application "Microsoft Excel"
                --do stuff here
                end using terms from
end tell

In ASOC projects it doesn’t seem to work that way. If I use the “of machine” command (from the AppleScript Studio days), I receive a “Cannot find remote machine” error.

Using Shane’s book as a guideline, i have my code currently written as follows…


set theRemoteMac to "eppc://username:password@ip_address"

set theApp to application ((theRemoteMac as text) & "/Microsoft Excel")
        using terms from application "Microsoft Excel"
            tell theApp
               --DO STUFF HERE
            end tell
        end using terms from

but this code produces the following error… Microsoft Excel got an error: Application isn’t running.

Any thoughts as to how I need to word my syntax to make the connection?

If there is any further information I can supply, please let me know.

Thanks everyone!

Hi,

you cannot launch an application on a remote machine directly. You have to tell the Finder to do that.
Fortunately the processes list is also available in Finder

tell application "Finder" of machine theRemoteMac
	using terms from application "Finder"
		if "Microsoft Excel" is not in (get name of processes) then open application file id "com.microsoft.Excel"
	end using terms from
end tell

I’m not sure whether the name of the process and the bundle identifier are correct.

Hi StefanK,
Thank you for the quick reply. Much appreciated. I will give this a try to see if it works in my Xcode project.

After I posted my original message, i realized where I went wrong in the syntax (it was in the call to the application itself). I made I minor change to my original code and I can make the remote connection as expected now…


set theRemoteMac to "eppc://username:password@ip_address"

set theApp to application ((theRemoteMac as text) & "/Microsoft Excel") -- ORIGINAL CODE
set theApp to application ((theRemoteMac as text) & "/Excel") -- NEW CODE - NOW WORKING
using terms from application "Microsoft Excel"
tell theApp
--DO STUFF HERE
end tell
end using terms from

the change is subtle, but after looking back at old ASStudio code, i found making this minor change works in ASOC as well.

Thanks again!

Hi willpeters- can you tell me which operating systems you are using, on the remote machine and the local machine?

My Apple Remote Events have been broken for some time. I’m running my script form El Capitan to a mac running Leopard and I probably need a newer remote operating system with updated security.