Remotely running an Applescript via ssh

Hi All,
I have been searching for a way to run an Applescript on a remote server via an ssh command. The idea would be ultimately to set up commands for certain scripts and then write them into an iphone so I can fire these off remotely with each action applied to a button.

The first step, of course, is figuring out how to run an Applescript remotely. So far, I have tried.

ssh username:password@192.168.112.198 // I realize this is an internal IP

I then navigated to the desktop (where the script “test.scpt” was placed and ran

./test.scpt

Of course, it did not run.

  1. Is there a command I am missing to do this?
  2. Would I have to use something like Squid-cache.org on a computer on a different network?

Thank you so much.

I’m not sure if this helps but I use the iPhone app TouchTerm to remotely login to my Mac and either run a script or execute AS via the terminal.

Examples:

osascript -e ‘tell application “System Events” to restart’

–or–

osascript ~/Documents/Scripts/“your_script_here.scpt”

(Note: the above file location is where I keep my AppleScripts)

Thank you for the info,
I will try that.

Hi Rob,
Thank you for the reply, when I run this, I get:

execution error: No user interaction allowed. (-1713)

I did some research and found this thread:

http://macscripter.net/viewtopic.php?id=26334

However, I am lost when they are saying name something run.applescript. I can rename my scripts suffix (scpt) to (applescript) but it translates it to garble. Any thoughts on this?

Thank you so much

When you run a script using osascript, you can get errors if you try to display a dialog box. For example, in normal aplescript you can just use display dialog “whatever”. However if you try this with osascript then you will see the error you described because osascript doesn’t know how to display a dialog. The fix is simple, just tell an application to display the dialog. I see from the link you provided they were using “Applescript Runner”. The Finder works too…

tell application "Finder" to display dialog "whatever"

As far as your question about “.applescript”… that file extension is for an applescript which was saved as a text file under the “Save As” menu. You do not need to use this. Save your script as a “scpt” or “scptd” compiled script and just use that path in your command.