Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

There is an iMac in our lab at university, running Mac OS X 10.7 Lion.

It is never used, so we have taken to using it to play music, as we can SSH to it, and it does not require any permissions to play music (using afplay).

Is there any way to stream radio, or any other music stream from the command line?

share|improve this question
up vote 1 down vote accepted

While not (strictly speaking) playing from the command line, you could use a set of AppleScripts (or AppleScript calls) wrapped in shell scripts to control a GUI player or website. In the likely case that the player or site doesn't directly support AppleScriptability, you can use AppleScript GUI scripting to control the mouse and keyboard.

If you're looking at a "normal" streaming radio station (i.e, one that has a downloadable file that specifies the stream), you can put that in iTunes and use its (relatively excellent) AppleScript dictionary to remotely control it.

With either option, if you want to get fancy, you can use remote scripting to send Apple Events from an arbitrary source machine to control your radio-iMac.

share|improve this answer
Are you able to do this if no one is physically logged in on the machine? – DanielGibbs Aug 3 '12 at 1:24
Maybe. Probably not. I did some poking around and I was able to get Pandora to launch with no GUI user logged in (only after sudo'ing to the root user), but the window never showed up and the music never played. (It also launched the Adobe AIR updater, so that may have been a/the problem. I also didn't wait very long.) – CajunLuke Aug 3 '12 at 1:52
I wasn't actually aware that you could stream radio through iTunes, thanks. I ended up just logging into the machine, opening a radio stream in iTunes and locking the screen. – DanielGibbs Aug 16 '12 at 21:14

I was interested to know the answer to this one myself, so I googled it. Here you go :-)

share|improve this answer
Thanks for the link, not quite what I was looking for. I want to play the music through the speakers, not record it to file. I'll try and see if I can get mplayer running, but I'm not sure, the latest version I can find is from 2005... – DanielGibbs Aug 3 '12 at 0:10


Use the relay function.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.