Apple TV Perl Plug-in

by Erica Sadun

On Sunday, with a hundred better things to do but no incentive to do them, I put together an Apple TV plug-in that allows you to run any Perl script you place into a folder in your home directory. (/Users/frontrow/perlbin). The idea is this: a lot of people know how to write Perl who don't want to learn to program Cocoa. And you can add new scripts from your normal office work computer (via ssh) but have them all available from Apple TV. You can do date & time, calendars, stock quotes, weather, and so forth. Scrape web pages, subscribe to RSS feeds, whatever.

The plug-in is here, and here are a few screen shots showing the plug-in in action. You can click each thumbnail to view the shots at full resolution.


http://www.oreillynet.com/mac/blog/images/PerlAppliance1scaled.jpg

The Perl plug-in in the main menu.


http://www.oreillynet.com/mac/blog/images/PerlAppliance2scaled.jpg

The submenu shows all files in /Users/frontrow/perlbin


http://www.oreillynet.com/mac/blog/images/PerlAppliance4scaled.jpg

Perl scripts, which are easy to create, can perform simple tasks like checking the date and time while displaying them in the Apple TV interface.


http://www.oreillynet.com/mac/blog/images/PerlAppliance7scaled.jpg

More complicated scripts can scrape webpages to gather information like this up-to-the-minute weather report.


14 Comments

Gresmi
2007-04-09 10:48:47
This is fantastic. I'm passing on the link to the people over at AppleTVHack to get the word out. I think this is a fantastic idea!
Chris
2007-04-09 12:28:59
This is cool! Ruby would be even better (Think Hpricot)!
Erica Sadun
2007-04-09 13:57:46
If you really want ruby, I can probably work it up. I'd have to embed the ruby executable in the plug-in because it's not there by default on Apple TV the way perl is.


Can I just copy /usr/bin/ruby from an Intel mac and expect it to work? Or are there libraries and things that would have to be installed?

JR
2007-04-09 17:28:04
How about a python plugin while you're at it.


Then we can get at porting some of the great XBMC python scripts that have been written over the years (and there are some great ones!)

Erica Sadun
2007-04-09 17:32:38
Again, no Python as a default install on Apple TV the way Perl is. And, from what I can tell, it requires an entire Framework installation, not just a single interpreter.
Mark
2007-04-09 22:10:01
This is very cool, thanks!


Wish I had an Apple TV to try it out on. Maybe later this year.

Thomas
2007-04-09 22:11:22
Is webkit available on the AppleTV?
Maybe I am dreaming, but it would be wonderful to combine this plugin with a webkit-canvas area in the "results page"... Just do a print to the results in HTML and get a nice layout :)
Sebastian
2007-04-10 00:54:11
Ruby would be great! Let us know if you get it working!
Erica Sadun
2007-04-10 14:13:13
I can't seem to find any webkit API calls for the Apple TV "Back Row" stuff, but I'm still new to it--and still looking around.
Mike
2007-04-10 19:09:36
Wow, you're good!
ChrisH
2007-05-03 03:05:41
Im not much of a perl programmer but if this could run PHP that would rock!!!! Please post if you think this would be difficult to do
Erica Sadun
2007-05-03 09:05:24
ChrisH: Updating from Perl to PHP is trivial. However, I know that Perl is installed by default on all Apple TVs. Is PHP? If you don't mind installing it on your Apple TV, then just change the line that says "/usr/bin/perl" to point to PHP instead and recompile.
James Thiele
2007-06-24 12:52:20
I noticed in you included the 'curl' executable. It executed fine for me on OS X 10.4.10. Am I correct in assuming that one could use any OS X exectable and launch it from Perl?
Erica Sadun
2007-06-25 09:31:50
James: It's just a standard OS X in there. A few things are missing, but curl is part of the standard Apple TV distro. -- E