[Noisebridge-discuss] BART train departure info from the command line

Jeremy K trochee at gmail.com
Mon Feb 9 22:22:48 UTC 2009


'eval' seems like a huge headache here -- and vulnerable to dumb user
behavior, e.g. giving 'wget http://goatse.cx/' as an argument --
compared to, say, using the case  ?

case station in
  rich)  RICH;
  # etc...



--jeremy

On Sun, Feb 8, 2009 at 2:58 AM, John Magolske <listmail at b79.net> wrote:
> Friday evening at 83c I was puzzling over how to make a shell script
> behave a certain way (it was the eval utility I was overlooking).
>
> At http://bart.gov/wireless/eta.aspx you can select a station from
> a pull-down list to check train departures, but I wanted a way to
> go straight to a station by specifying it on the command-line. For
> example, `bart 16` or `bart sfo` to display real-time departures from
> the 16th/Mission or SF Airport stations. Anyhow, I thought I'd pass
> it along here for any BART traveling command-line aficionados.
>
> John
>
>
> ----
>
>
> #!/bin/sh
> # A command line tool for checking BART trains departing a given station
> # Requires elinks as written here, but that can replaced with another
> # browser if you so desire...
> # (c)2008 John Magolske, GPL v3
> # Last edit: 2009/02/07 Sat 13:13 PST
>
> # If no station is specified go to the bart.gov/wireless pull-down list
> [ "$#" -eq 0 ] &&\
> elinks -no-connect 1 http://bart.gov/wireless/eta.aspx && exit 0
>
> # created easier to remember (for me) short-names for each station:
> ash="ASHB"      # Ashby
> bal="BALB"      # Balboa Park
> cas="CAST"      # Castro Valley
> bay="BAYF"      # Bay Fair
> civ="CIVC"      # Civic Center
> col="COLS"      # Coliseum/Oakland
> colma="COLM"    # Colma
> con="CONC"      # Concord
> daly="DALY"     # Daly City
> berk="DBRK"     # Downtown Berkeley
> dub="DUBL"      # Dublin/Pleasanton
> cern="DELN"     # El Cerrito del Norte
> cerp="PLZA"     # El Cerrito Plaza
> emb="EMBR"      # Embarcadero
> free="FRMT"     # Fremont
> fruit="FTVL"    # Fruitvale
> glen="GLEN"     # Glen Park
> hey="HAYW"      # Hayward
> laf="LAFY"      # Lafayette
> lake="LAKE"     # Lake Merritt
> mac="MCAR"      # MacArthur
> mill="MLBR"     # Millbrae
> mont="MONT"     # Montgomery St.
> nberk="NBRK"    # North Berkeley
> ncon="NCON"     # North Concord/Martinez
> orin="ORIN"     # Orinda
> pit="PITT"      # Pittsburg/Bay Point
> phill="PHIL"    # Pleasant Hill
> pow="POWL"      # Powell St.
> rich="RICH"     # Richmond
> rock="ROCK"     # Rockridge
> sanb="SBRN"     # San Bruno
> sfo="SFIA"      # San Francisco Int\'l Airport
> slean="SANL"    # San Leandro
> shay="SHAY"     # South Hayward
> ssf="SSAN"      # South San Francisco
> uni="UCTY"      # Union City
> wcreek="WCRK"   # Walnut Creek
> woak="WOAK"     # West Oakland
>
> eval sta="\$$1"
>
> # variables can't begin with a number, for numbered stations do it like:
> [ "$1" = "16" ] && sta="16TH"   # 16th St. Mission (SF)
> [ "$1" = "24" ] && sta="24TH"   # 24th St. Mission (SF)
> [ "$1" = "12" ] && sta="12TH"   # 12th St. Oakland City Center
> [ "$1" = "19" ] && sta="19TH"   # 19th St. Oakland
>
> # call up bart.gov/wireless & go directly to the specified station
> elinks -no-connect 1 http://bart.gov/wireless/stationdetails.aspx?station="$sta"
>
>
>
> --
> John Magolske
> http://B79.net/contact
> _______________________________________________
> Noisebridge-discuss mailing list
> Noisebridge-discuss at lists.noisebridge.net
> https://www.noisebridge.net/mailman/listinfo/noisebridge-discuss
>



More information about the Noisebridge-discuss mailing list