How to Start iTunes from a Shell Script
Mac OS X supports a variety of tools inherited from UNIX, including shell scripts. Shell scripts are text files that contain a list of Terminal commands. These commands are executed in sequence when you run the script. While you can’t execute iTunes or another OS X application bundle by directly specifying its location, as you would with a Terminal command, you can use the “open” command on Mac OS X to start iTunes or another application bundle from a shell script.
Instructions
-
-
1
Open a text editor on your Mac.
-
2
Add the following line to the top of the file:
#!/bin/bash
-
-
3
Type the following text onto a new line in your file:
open -a /Applications/iTunes.app
-
4
Save the text file with the .sh file extension.
-
5
Open a Terminal window by double-clicking the Terminal icon in the Applications folder.
-
6
Type the following command into the Terminal, replacing “/path/to/script.sh” with the path to the shell script you created on your Mac. This command makes the shell script executable.
chmod +x /path/to/script.sh
-
1
Tips & Warnings
Add other commands on their own lines before or after the “open -a /Applications/iTunes.app” command to have your shell script perform more actions. You can also add this line to any existing shell script.
References
- Photo Credit Justin Sullivan/Getty Images News/Getty Images