summaryrefslogtreecommitdiff
path: root/shtrains.sh
blob: 7b9b2d06a90f29f1531c316f01fad5b46860d863 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#!/bin/bash

links -dump 'http://transilien.mobi/pam/TempReelSaisieDepartSubmit.do?debutDepart=Courbevoie&tous=Tous+trains' >trains.tmp

cat trains.tmp | \
while true
do
	while true
	do
		read PATTERN || break
		if [[ $PATTERN =~ \ *[A-Z]{4}\ *(.*)\ *Voie ]]; then
			PATTERN=${BASH_REMATCH[1]}
			break
		fi
	done
	read STATION || break
	read UGUU || break
	if [[ $UGUU =~ Supprime ]]; then
		read UGUU || break
		continue
	fi
	#[[ $STATION =~ Versailles\ Rive\ Droite ]] && STATION="Versailles Rive Droit"
	if [ -n "$*" ]; then
		[[ $STATION =~ $@ ]] && echo "$PATTERN $STATION"
	else
		echo "$PATTERN $STATION"
	fi
done

exit 0