2007
11.19

After chatting with [ my buddy Dave ](http://mortysworld.blogspot.com)
about how awesome it is to show off using terminal to !1337 computer
users I realized how often I’m sitting at command-line listening to music
in iTunes and wondered how to control iTunes with a shell script.

I searched around an found [ this ](http://www.macosxhints.com/article.php?story=20011108211802830)
article on the topic but of course wanted many tweaks of my own so I’ve
wrote the following script that should allow anyone to control iTunes in terminal
or via SSH remotely.

### Possible Uses ###
The implications are pretty neat if you think about it.

  • DJ a party from a laptop, iPhone, or mobile with SSH
  • Control your home or office music server remotely
  • Scare the heck out of your roommates

### The Code ###

#!/bin/sh
#
####################################
# iTunes Command Line Control v1.0
# written by David Schlosnagle
# created 2001.11.08
# edited by Jon Todd 2007.11.20
####################################

showHelp () {
echo "-----------------------------";
echo "iTunes Command Line Interface";
echo "-----------------------------";
echo "Usage: `basename $0`

### Installation ###

Write this code to a file called “itunes” and put it in your bin directory

mkdir ~/bin
mv pathToFile/itunes.sh ~/bin
chmod u+x ~/bin/itunes

Ensure ~/bin is in your path

### Run it ###

[jtodd@local:~]$ itunes status
State: 		stopped
Volume: 	100
Playlist: 	Combo
Shuffle: 	false
[jtodd@local:~]$ itunes play
Playing iTunes.
[jtodd@local:~]$ itunes status
State: 		playing
Volume: 	100
Playlist: 	Combo
Shuffle: 	false
Artist: 	Jamiroquai
Album: 		synkronized
Track: 		Canned Heat
[jtodd@local:~]$ itunes vol 50
Changing iTunes volume level.
[jtodd@local:~]$ itunes pause
Pausing iTunes.
[jtodd@local:~]$ itunes vol 100
Changing iTunes volume level.
[jtodd@local:~]$ itunes play
Playing iTunes.

### Remote Control ###

[jtodd@remote:~]$ ssh local
[jtodd@local:~]$ itunes status
State: 		playing
Volume: 	100
Playlist: 	Combo
Shuffle: 	false
Artist: 	Jamiroquai
Album: 		synkronized
Track: 		Canned Heat

1 comment so far

Add Your Comment
  1. Nice Post! you can also SCP this file from remote to local, then SSH and have control. That way you can control not just your box, but any box that would have ITunes that your friends’ can share at a party.