On May 21, 2007, at 8:58 AM, Mark J. Reed wrote: Also, calling the application as a shell script requires the AppleScript to know the absolute path of the application before shipping the script. Since this application, and its associated AppleScripts will be distributed to users, who may put the application anywhere on their hard drive, I don't think a shell script solution will work.
Ok, wait.
EITHER
(1) you have an icon for the app that the users double-click, in which case the users have to be able to find that icon . . .
OR
(2) you have a command-line application, which can reside anywhere in the user's PATH, and you only need to know the name.
Which is it?
Well, it is an app. that the user can double-click on to start. But there's no reason why I can't also call it from the command line. Under normal circumstances the user can double click "Foobar.app" to start the app. But occasionally they would like to get "Alternate Behavior 1". Which calls "Foobar.app" with the argument "alternate1". So in a sense it is both, a Double Clickable .app bundle, and a command-line program. This being the case I thought using an AppleScript for this would have been a good choice to make alternate behaviors also double-clickable.
If the application is built for OS X with the full .app directory etc, then you can supply parameters to be passed to the executable when the app is launched (by double-click or open) by adding them to a text file in the resources directory.
The Info.plist file is static. I can't change the arguments in the Info.plist on the fly. Unless you are suggesting that I can. If so, can you please point me to where I can learn more about this?
For "do shell script" I believe you can use nohup, backgorunding (&), and I/O redirection to get the app to go into the background without leaving an open window. But I'm not sure what AppleScript is adding to the mix in this case - why not just make the launchable app a shell script in the first place?
Because this application needs to also be usable by other services on the computer (such as Login Items), and Unix shell scripts do not seem to be able to be executed by those services. Although, as you suggest, I can wrap my program in a shell script, and then wrap that in a AppleScript. But that doesn't seem like a very elegant solution to me.
So maybe I'm reading too much into this, but apparently there is no way to pass command line arguments to an application via AppleScript. In fact it is looking like it is impossible to pass command line arguments to applications (and by this I mean applications in the /Applications folder that end in .app) at all.
Coming from a Unix/Linux world this is a completely different paradigm, as I am used to being able to pass flags and arguments to programs (GUI and command-line) to customize their behavior. So I hope you'll pardon me if I am asking what might seem like obvious-to-the-mac-developer questions.
Thanks again for your help, Mike
-- ********************************* Mike Dougherty 858.232.3635
*********************************
|