#!/bin/bash TICKER=$1 CACHEFILE=/home/administrator/.quotecache/$TICKER URL='http://quotes.nasdaq.com/quote.dll?page=xml&mode=stock&symbol='$TICKER function refresh() { echo refresh $TICKER #wget -q $URL -O $CACHEFILE if [ $? != 0 ] then echo wget failed fi } TIMESTAMP=/home/administrator/.quotecache/TIMESTAMP HH=`date +"%H"` MM=`date +"%M"` MM=`expr $MM - 5` touch --date="$HH:$MM" $TIMESTAMP if ! [ -f $CACHEFILE ] then refresh fi if [ $CACHEFILE -ot $TIMESTAMP ] then refresh fi case $2 in last) field='last-sale-price' ;; change) field='net-change-price' ;; vol) field='share-volume-qty' ;; *) exit 1 ;; esac sed " /^#^# s##^# " < $CACHEFILE | cut -d^ -f2,4