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: how can an apple script get parameters (when invoking it from the java code)?



This is true, and to be more sure, the first param should be /usr/bin/osascript . And even that's 100% as the user may have moved it.


On 21 Oct 2007, at 18:51, Greg Guerin wrote:

So if summer.scpt is in /tmp ...

String exec = "osascript -e 'run script posix file \"/tmp/summer.scpt\"
with parameters {4,5,6}'";

That string will work as a shell command-line, but it won't work as an arg
to Runtime.exec().  Runtime.exec() is not a shell; it does not understand
quoting.  It always breaks a String into cmd-line args at whitespace.

Instead, use the String[] form of exec(), with each param in its own String:
  String[] cmdArgs ={ "osascript", "-e",
    "run script posix file \"/tmp/summer.scpt\" with parameters {4,5,6}" };
  Process process = Runtime.getRuntime().exec( cmdArgs );

  -- GG


 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

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

This email sent to email@hidden

References: 
 >Re: how can an apple script get parameters (when invoking it from the java code)? (From: Greg Guerin <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.