Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AppleScript with widget.system



Thanks to all for helping,

I stumbled onto the solution a couple of hours ago, and posted an answer to my own question, but now I see I replied to myself, not to the list!

In any event, the subtleties of the parsing may explain why "/usr/bin/ osascript -e 'tell application \"TextEdit\" activate end tell'" will execute properly (without newlines) but (substituting Mail for TextEdit) "/usr/bin/osascript -e 'tell application \"Mail\" activate end tell'" won't.

I'm happy that I have a solution though, so I'm willing to live with the mystery.

Thanks again,
John

On May 19, 2005, at 3:12 PM, John Louch wrote:

AppleScript wants newlines. If you were able to get error reporting, you'd
find that it was complaining like this:


25:26: syntax error: Expected end of line but found unknown token. (-2741)

Try:

    var commandLine = "/usr/bin/osascript -e 'tell application
\"Mail\"\nactivate\nend tell\n'";
    widget.system(commandLine, null);

The system call just hands whatever your command is over to /bin/ sh for
interpretation, though by that time your Javascript will have already done
some: \" to " and \n to a real newline and so forth. So you can always test
on the command line. Also, system will for a process for every call, so I'd
generally prefer to do this in objC anyway:




This is not exactly correct. The system call will try to exec the command
directly unless the command has metacharacters in it. If it has
metacharacters it will then use /bin/sh.


Thanks,
jl

_______________________________________________ Do not post admin requests to the list. They will be ignored. Dashboard-dev mailing list (email@hidden) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/dashboard-dev/email@hidden

This email sent to email@hidden
References: 
 >Re: AppleScript with widget.system (From: John Louch <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.