I have an Applescript Droplet application that I need to run from terminal. I can use osascript
or even just open
to open the AS App, but that will run its on run
handler, not the on open
droplet handler I need to be run. I tried passing the "dropped" file in (osascript /Path/To/App.app /Path/To/Droppings.txt
), but it still runs the on run
handler. Is there a way to do this? And if not with bash, is it possible from another AppleScript? Thanks.
MacOS – Running an AS droplet from Terminal
applescriptbashmacosterminal
Related Question
- MacOS – How to prevent MacVim from inheriting .profile as if it was Bash itself
- Droplet with a progress bar
- Execute terminal command “rsync” from BetterTouchTool
- MacOS – How to control the Terminal in the current space with AppleScript
- Installing ffmpeg from dmg and then running from a terminal, is there a better way
Best Answer
You can use another AppleScript that tells Finder to open files with the droplet application.
For example save this script as
/Applications/droplet.app
in AppleScript Editor:Then run:
osascript -e 'on run {f}' -e 'tell app "Finder" to open POSIX file f as alias using POSIX file "/Applications/droplet.app"' -e end /bin/test
To open multiple files, convert the list of arguments to a list of file objects:
Alternatively, create the droplet application with Automator instead of AppleScript Editor:
Then run
open -a droplet2 /bin/test
.The
run
handler is also used for files dropped on the application. A handler namedopen
does not have any special meaning.One drawback of using Automator applications is that there is a relatively long delay before they are run.