NextTram

Melbourne TramTracker command line interface

Melbourne's tram operator, Yarra Trams provides a web and SMS based tram tracking service called TramTracker, which can tell you what time the next three trams will arrive at a particular stop. It uses a combination of real-time information and scheduled timetables, depending on whether the next tram has left the terminus yet.

It has a couple of flaws, however. Firstly, it can only be accessed via a web-browser, which is inconvenient. Secondly, it's not able to group multiple stops in one request, so if you're within walking distance of several different tram routes, you need to make multiple requests to find out which one leaves next.

NextTram is a perl script which allows access to the TramTracker service from the command-line. It can be given multiple stop numbers and it will retrieve the times for the next three trams at each of them and then sort the results. For example, to find the time of the next tram to the city from Lygon St, Sydney Rd or Grantham St, near Brunswick Rd, Brunswick:

$ ./nexttram 1419 1259 1216
55:Domain Interchange:0
19:Flinders St City:6
1:Sth Melb Beach:7
8:Toorak:11
8:Toorak:19
55:Domain Interchange:24
19:Flinders St City:27
55:Domain Interchange:44
19:Flinders St City:46

The output is: Route Number : Destination : Time to Arrival (in minutes)

Stop numbers can be found here.

The script needs the following perl modules to operate: HTML::TableExtract, Unicode::MapUTF8, LWP::UserAgent and Date::Parse. For Debian and Ubuntu users, these can be installed with:

apt-get install libwww-perl libunicode-maputf8-perl \
libhtml-tableextract-perl libtimedate-perl

Paul Dwerryhouse, paul@dwerryhouse.com.au, 2008-07-13