Grant McWilliams

Tech Programming Bash Where's My Bus? Finding your bus with BASH.

Where's My Bus? Finding your bus with BASH.

While demonstrating that you can use BASH for more than system administration I put together this script that accesses OneBusAway's ReST API to show what buses are coming to your stop next, their scheduled arrival time and their real arrival time (for King County Metro). You can download it from the Downloads section if you wish -

This script was made on Ubuntu Linux using BASH 3.2 and requires wget and xml2. Wget is usually installed on Linux but I had to install xml2 so I have the script checking for that.  wheresmybus3.sh (1 kB)

Syntax: wheresmybus.sh stop_id

Example: wheresmybus.sh 1_400

Route Number: 358E

Destination: DOWNTOWN SEATTLE VIA AURORA AVE N

Actual Arrival Time: 0 Minutes
Scheduled Arrival Time: -8 Minutes

 



Route Number: 2

Destination: MADRONA PARK VIA E UNION ST

Actual Arrival Time: 0 Minutes

Scheduled Arrival Time: 4 Minutes

 

If you don't know what the agency number is (and who does?) just leave it out and wheresmybus.sh will give you a list. The example above would show the arrival times for King County Metro's stop number 400. Output will look like this.

Tech Programming Bash Where's My Bus? Finding your bus with BASH.