Created
March 27, 2012 18:21
-
-
Save jbedo/2218677 to your computer and use it in GitHub Desktop.
Fetches next train times for RER D line to/from Paris and Evry Courcouronnes and displays minutes remaining
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/rc | |
urlfrom='http://www.transilien.mobi/TempReelSaisieSubmit.do?debutDepart=chatelet&debutArrivee=evry+courcouronnes' | |
urlto='http://www.transilien.mobi/TempReelSaisieSubmit.do?debutDepart=evry+courcouronnes&debutArrivee=chatelet' | |
url=$urlfrom | |
for(i) switch $i { | |
case -t | |
url=$urlto | |
} | |
hget $url | tr -d ' | |
' | awk ' | |
BEGIN{train[0] = 0} | |
/[A-Z][A-Z]P[A-Z]$/ {train[++train[0]] = $1} | |
/[0-9]+h[0-9]+/ {split($1, w, "[h*]"); time[train[0]] = w[1] * 60 + w[2]} | |
END{ | |
for(i = 1; i <= train[0]; i++) | |
printf("%s: %sm\n", train[i], time[i] > time[0] ? time[i] - time[0] : "ERR"); | |
} | |
' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment