Ärgernis: Wie komme ich zum Röschenhof?
Fix:
CODE
scherge ~ # ./t "Messe Dresden"
1. Fahrt am 30.11.2008 23:25 - 23:58 Uhr
Zeit Linie Station
23:25 13 ab Dresden Mockritzer Straße
23:33 an Dresden Straßburger Platz
23:35 2 ab Dresden Straßburger Platz
23:49 an Dresden Bahnhof Mitte
23:53 alita ab Dresden Bahnhof Mitte
23:58 an Dresden Messe Dresden
2. Fahrt am 01.12.2008 05:42 - 06:09 Uhr
Zeit Linie Station
05:42 9 ab Dresden Mockritzer Straße
05:46 an Dresden Querallee
05:51 75 ab Dresden Querallee
06:09 an Dresden Messe Dresden
3. Fahrt am 01.12.2008 06:07 - 06:29 Uhr
Zeit Linie Station
06:07 75 ab Dresden Mockritzer Straße
06:29 an Dresden Messe Dresden
4. Fahrt am 01.12.2008 06:27 - 06:49 Uhr
Zeit Linie Station
06:27 75 ab Dresden Mockritzer Straße
06:49 an Dresden Messe Dresden
...
Ubuntu: sudo apt-get install gawk (sollte IMHO der linux standard sein, aber irgendwelche Idioten haben bei Ubuntu (auch Debilian?) mawk installiert.)
> t; chmod +x t;
In der t sollte stehen (Editor):
#!/bin/bash
dststation=${1:-Wo will ich meistens hin? - Dein default Wert!}
srcstation=${2:-Wo steige ich meistens ein? Dein default Wert!}
awk -vrequest="http://efa.vvo-online.de:8080/dvb/XSLT_TRIP_REQUEST2?sessionID=0&requestID=0&language=de&usage=xslt_trip&execInst=normal&command=&ptOptionsActive=-1&itOptionsActive=&itDateDay=`date +%d`&itDateMonth=`date +%m`&itDateYear=`date +%y`&place_origin=Dresden&placeState_origin=empty&type_origin=stop&name_origin=${srcstation/ /%20}&nameState_origin=empty&place_destination=Dresden&placeState_destination=empty&type_destination=stop&name_destination=${dststation/ /%20}&nameState_destination=empty&itdTripDateTimeDepArr=dep&itdTimeHour=`date +%H`&idtTimeMinute=`date +%M`" -vRS="<tr[^>]*>|</tr>" -vFS='<td[^>]*>|</td>|\\("|"\\)' 'BEGIN { route=0; curr=0; s="/inet/tcp/0/efa.vvo-online.de/8080"; print "GET " request " HTTP/1.1\r\nHost: efa.vvo-online.de\r\nUser-Agent: akts!zr\r\nAccept: */*\r\nConnection: close\r\n\r\n" |& s; while (s |& getline) { if($0 ~ /#ROUTE/) { split($0, a, /<a[^>]*>|<\/a>/); routes[++route]=a[2]; continue; } if($0 ~ /"ROUTE_[0-9]"/) { print routes[++curr]; print " Zeit Linie Station"; continue; } if($2 ~ /^[0-9][0-9]:[0-9][0-9]/) { split($11, a, / /); line=a[2]; printf (" %s %5s %s\n", $2, line, $4 " " $6); } } }' | perl -npe 's/([\x80-\xff])/(chr(0xc0 | ((ord($1) >> 6) & 0x3f)).chr(0x80 | (ord($1) & 0x3f)))/eg'
Wenn du keine UTF-8 Console nimmst, dann entferne alles ab (und inklusive) `| perl -npe...'
Is wohl noch watt Beta, aber was solls! Gute Nacht!
p.s.: Achso: Es geht auch: ./t "Mein Ziel" "Meine Haltestelle"... daher müssen fortan diese " bei zusammengesetzten begriffen verwendet werden, z.b. ./t "Fritz Foerster Platz" (Wenn einem `./t TU' zu banal is...)
p.p.s.: Neue, revidierte Version mit Haltestellenpräzisierung:
CODE
Wie sieht HSP aus?
scherge ~ # ./t Messe Mock
Gehts etwas genauer?
Einstieg: Campingplatz Mockritz, Mockethaler Straße, Mockritz, Mockritzer Straße?
Ausstieg: Messe Dresden, Ostragehege Messehalle 1?
---
#!/bin/bash
dststation=${1:-Wo will ich meistens hin? - Dein default Wert!}
srcstation=${2:-Wo steige ich meistens ein? Dein default Wert!}
awk -vrequest="http://efa.vvo-online.de:8080/dvb/XSLT_TRIP_REQUEST2?sessionID=0&requestID=0&language=de&usage=xslt_trip&execInst=normal&command=&ptOptionsActive=-1&itOptionsActive=&itDateDay=`date +%d`&itDateMonth=`date +%m`&itDateYear=`date +%y`&place_origin=Dresden&placeState_origin=empty&type_origin=stop&name_origin=${srcstation/ /%20}&nameState_origin=empty&place_destination=Dresden&placeState_destination=empty&type_destination=stop&name_destination=${dststation/ /%20}&nameState_destination=empty&itdTripDateTimeDepArr=dep&itdTimeHour=`date +%H`&idtTimeMinute=`date +%M`" -vRS="<tr[^>]*>|</tr>" -vFS='<td[^>]*>|</td>|\\("|"\\)' 'BEGIN { isDest=0; route=0; curr=0; s="/inet/tcp/0/efa.vvo-online.de/8080"; print "GET " request " HTTP/1.1\r\nHost: efa.vvo-online.de\r\nUser-Agent: akts!zr\r\nAccept: */*\r\nConnection: close\r\n\r\n" |& s; while (s |& getline) { if($0 ~ /option value="[0-9]+:[0-9]+"/) { if($0 ~ /name_destination/) { isDest = 1; } split($0, a, /<option[^>]*="[0-9]+:[0-9]+">|<\/option>/); if(isDest) for(pos = 2; a[pos]; pos += 2) dest = dest (dest ? ", " : "") a[pos]; else for(pos = 2; a[pos]; pos += 2) src = src (src ? ", " : "") a[pos]; continue; } if($0 ~ /#ROUTE/) { split($0, a, /<a[^>]*>|<\/a>/); routes[++route]=a[2]; continue; } if($0 ~ /"ROUTE_[0-9]"/) { print routes[++curr]; print " Zeit Linie Station"; continue; } if($2 ~ /^[0-9][0-9]:[0-9][0-9]/) { split($11, a, / /); line=a[2]; printf (" %s %5s %s\n", $2, line, $4 " " $6); } } if(src || dest) { print "Gehts etwas genauer?"; if(src) { print "Einstieg: " src "?"; } if(dest) { print "Ausstieg: " dest "?"; } } }' | perl -npe 's/([\x80-\xff])/(chr(0xc0 | ((ord($1) >> 6) & 0x3f)).chr(0x80 | (ord($1) & 0x3f)))/eg'
p.p.p.s.: Noch eine revision (Unter anderem wird jetzt Nummer der S-Bahn angezeigt:
CODE
#!/bin/bash
dststation=${1:-Default Wohin}
srcstation=${2:-Default Einstiegshaltepunkt}
awk -vrequest="http://efa.vvo-online.de:8080/dvb/XSLT_TRIP_REQUEST2?sessionID=0&requestID=0&language=de&usage=xslt_trip&execInst=normal&command=&ptOptionsActive=-1&itOptionsActive=&itDateDay=`date +%d`&itDateMonth=`date +%m`&itDateYear=`date +%y`&place_origin=Dresden&placeState_origin=empty&type_origin=stop&name_origin=${srcstation/ /%20}&nameState_origin=empty&place_destination=Dresden&placeState_destination=empty&type_destination=stop&name_destination=${dststation/ /%20}&nameState_destination=empty&itdTripDateTimeDepArr=dep&itdTimeHour=`date +%H`&idtTimeMinute=`date +%M`" -vRS="<tr[^>]*>|</tr>" -vFS='<td[^>]*>|</td>|\\("|"\\)' 'BEGIN { isDest=0; route=0; curr=0; s="/inet/tcp/0/efa.vvo-online.de/8080"; print "GET " request " HTTP/1.1\r\nHost: efa.vvo-online.de\r\nUser-Agent: akts!zr\r\nAccept: */*\r\nConnection: close\r\n\r\n" |& s; while (s |& getline) { if($0 ~ /option value="[0-9]+:[0-9]+"/) { if($0 ~ /name_destination/) isDest = 1; split($0, a, /<option[^>]*>|<\/option>/); if(isDest) for(pos = 2; a[pos]; pos += 2) dest = dest (dest ? ", " : "") a[pos]; else for(pos = 2; a[pos]; pos += 2) src = src (src ? ", " : "") a[pos]; continue; } if($0 ~ /#ROUTE/) { split($0, a, /<a[^>]*>|<\/a>/); routes[++route]=a[2]; continue; } if($0 ~ /"ROUTE_[0-9]"/) { print routes[++curr]; print " Zeit Linie Station"; continue; } if($2 ~ /^[0-9][0-9]:[0-9][0-9]/) { split($11, a, / /); line=a[2]""a[3]; printf (" %s %5s %s\n", $2, line, $4 " " $6); } } if(src || dest) { print "Gehts etwas genauer?"; if(src) print "Einstieg: " src "?"; if(dest) print "Ausstieg: " dest "?"; } }' | perl -npe 's/([\x80-\xff])/(chr(0xc0 | ((ord($1) >> 6) & 0x3f)).chr(0x80 | (ord($1) & 0x3f)))/eg'