Skip to main content

Run AppleScript or JavaScript for Automation (JXA) from the command line.

# To run an AppleScript command:
osascript -e 'say "Hello world"'

# To run multiple AppleScript commands:
osascript -e 'say "Hello"' -e 'say "world"'

# To run a compiled (.scpt), bundled (.scptd), or plaintext (.applescript) AppleScript file:
osascript path/to/apple.scpt

# To get the bundle identifier of an application (useful for open -b):
osascript -e 'id of app "Application"'

# To run a JavaScript command:
osascript -l JavaScript -e 'console.log("Hello world");'

# To run a JavaScript file:
osascript -l JavaScript path/to/script.js