Forrest logo
back to the osascript tool

osascript:tldr:a7161

osascript: Run an AppleScript command.
$ osascript -e "${say 'Hello world'}"
try on your machine

The command "osascript -e" is used to execute AppleScript commands from the command line in macOS. In this case, the command is executing an AppleScript command to make the system speak the phrase "Hello world".

Let's break down the command:

  1. "osascript": It is the command-line tool that serves as the interface to execute AppleScript commands or scripts.

  2. "-e": It signifies that the following argument is an AppleScript code or command to be executed.

  3. "${say 'Hello world'}": This is the actual AppleScript code to be executed. Inside the curly braces "${}", the AppleScript code is wrapped to ensure the inner shell variables are preserved.

In the given example, the AppleScript code is using the "say" command, which is used to convert text to speech in macOS. It takes a string argument, which in this case is "Hello world". So, when the command is run, it will make the system speak the phrase "Hello world" out loud.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the osascript tool