
if [ -z "$1" ] || [ -z "$2" ]
then
	echo "Usage: getdirections.sh [start address] [destination address]"
	echo "example: ./getdirections.sh \"195 Broadway, New York, NY\" \"10 market st, san franciscoi,ca\""
	exit
fi

start=`echo $1|./urlencode.sh`
end=`echo $2|./urlencode.sh`

wget -t0 -o log -O - "http://local.live.com/directions.ashx?start=${start}&end=${end}&units=mi&mkt=en-us"|strings|head -1|sed -e 's/new VE_RouteInstruction(/\n====/g'|grep "====" | {
read line
count=1
while [ -n "$line" ]
do
	#echo "$line"
	direction=`echo $line|cut -d \' -f2|sed -e 's/,/;/g'`
	coords=`echo $line|cut -d \' -f3|cut -b2-200|sed -s 's/)//g'| sed -e 's/]//g'`
	echo "$count,$coords$direction"
	let count=count+1
	read line
done
}
