osascript

From RaySoft

osascript executes the given script. It was designed for use with AppleScript, but will work with any 'Open Scripting Architecture' (OSA) language. To get a list of the 'OSA' languages installed on your system, use 'osalang'.[1]

Documentation

Syntax

osascript [PARAMETER ...] [-e STATEMENT | FILE] [ARGUMENT ...]

Parameters

-e SCRIPT
Enter one line of a SCRIPT. If -e is given, osascript will not look for a filename in the argument list. Multiple -e options may be given to build up a multiline script. Because most scripts use characters that are special to many shell programs (e.g. AppleScript uses single and double quote marks, (, ) and *), the statement will have to be correctly quoted and escaped to get it past the shell intact.
-l LANGUAGE
Override the LANGUAGE for any plain text files. Normally, plain text files are compiled as AppleScript.

Examples

Set the speaker's volume & play music
osascript <<-EOS
	set volume without output muted
	set volume output volume 100
EOS

afplay --volume 1 "${HOME}/Music/Shakra/Infected/03 The One.m4a"
NOTE:
You never know - I'm An Idiot @ xkcd

References

  1. man 1 'osascript'