ssh can't exeute applescript

i tried too run a applescript remotely using ssh but it wil not work

[MOM-MAC:~] greenthing% sudo osascript -e 'tell app "Finder" to activate' -e 'tell app "Finder"
Unmatched '.
to display dialog "I see you!"'[MOM-MAC:~] greenthing% to display dialog "I see you!"'

that is exactly what it says

any help would be appreciated

Xelapond

Mac OS X (10.4.7), Accessing 10.2.8

Posted on Aug 28, 2006 7:33 PM

Reply
6 replies

Aug 28, 2006 8:24 PM in response to Xelapond

Hi Xelapond,
I can only guess at what happened in lieu of details. You pasted that command into the command line, right? It's my guess that you copied a command that wrapped onto two lines and you also copied a newline character that cause the first line to be executed before the command was completed. Paste the command into a text editor that doesn't wrap lines, delete the newline and copy the command again now that it's all on one line. Next time you paste it into the command line, it shouldn't execute until you hit the return key. The terminal will probably wrap the line but the terminal won't put in a newline so the line will be treated as a single line no matter how it's wrapped.

It's questionable whether the command will work anyway. Commands executed in a secure shell login probably execute in a different execution context from the GUI in which the Finder runs. You can read about execution contexts in Technical Note TN2083: Daemons and Agents. It's difficult to determine from that TechNote whether your command will work but don't be too disappointed if it fails.
--
Gary
~~~~
If only you knew she loved you, you could face the
uncertainty of whether you love her.

Aug 28, 2006 8:21 PM in response to Xelapond

Be sure you escape your end of line characters with a backslash \

<pre>this is a \
single line since the backslash \
continues the previous line and doesn't start to execute the command \
until you press return without a preceeding backslash
</pre>

I would guess you eventually want something like:
<pre>% ssh user@machine sudo -e 'one thing' \
-e 'another tell with "embedded quotes" '</pre>

Aug 28, 2006 8:43 PM in response to Xelapond

Hi, it's actually telling you what's wrong. You have an unmatched apostrophe character somewhere. It looks like your command was on two lines. It all has to be on one line:

<pre class="command">osascript -e 'tell app "Finder" to display dialog "I see you!"'</pre>

Also, you don't need to use sudo.

EDIT: This works, assuming you're already logged in via SSH, so it's a two-step process. Log in, then run the command.

charlie

Aug 29, 2006 9:11 PM in response to Gary Kerbaugh

Thanks for the pointer to the note, Gary!

If you're ssh'd in to a user (local or remote) that is not the current "owner" of the GUI, and is not root, you'll get the error message<pre>kCGErrorRangeCheck : Window Server communications from outside of session allowed for root and console user only
INIT_Processeses(), could not establish the default connection to the WindowServer.Abort trap</pre>

If you're ssh'd in as root (or as an admin, and sudo'd to root), or ssh'd in as the user that "owns" the GUI, then the Finder icon will bounce in the Dock, and clicking on it will display your message. (I tried it!)

Putting this in a crontab entry -- I mean, a launchd entry -- as the root user, could be a fun way to scare unauthorized users!

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

ssh can't exeute applescript

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.