[sf-lug] BART train departure info from the command line
Jesse Zbikowski
embeddedlinuxguy at gmail.com
Sun Feb 15 15:04:46 PST 2009
This is a good idea. I wanted to see the results on stdout like a
normal utility instead of going in to the browser, so I used elinks
-dump. Also I used "head" and "tail" to extract the departure times.
--- bart.orig 2009-02-15 14:47:21.000000000 -0800
+++ bart 2009-02-15 14:49:03.000000000 -0800
@@ -59,7 +59,9 @@
[ "$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"
+elinks -dump -no-references -no-numbering -no-connect 1 \
+ http://bart.gov/wireless/stationdetails.aspx?station="$sta" \
+ | head -n -11 | tail -n +4
## end of script ##
On Sun, Feb 8, 2009 at 12:39 PM, John Magolske <b79net at gmail.com> wrote:
> #!/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"
>
> ## end of script ##
More information about the sf-lug
mailing list