Skip to content

Instantly share code, notes, and snippets.

@jbedo
Created March 27, 2012 18:21
Show Gist options
  • Save jbedo/2218677 to your computer and use it in GitHub Desktop.
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
#!/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