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 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122
|
#!/bin/bash
#
# Helper to run the Quote.com (Lycos) Lice Charts applet
#
#
# Width and height of applet window.
#
WIDTH=700
HEIGHT=350
USERNAME=demo
PASSWORD=demo
UA="Mozilla/4.0 (compatible; MSIE 5.5; Windows 98)"
PATH=$PATH:$HOME/bin:/usr/share/linuxtrade/bin
LT=$HOME/.linuxtrade
YEST=$LT/lc.yesterday
RC=$LT/rc
APPLET=lc.applet
#
# Get username, password, and geometry
#
geom=
lcopts=
while read tag eq val
do
case "$tag" in
lc_user) USERNAME="$val";;
lc_pass) PASSWORD="$val";;
lc_geom) geom="$val";;
lc_opts) lcopts=",$val";;
esac
done < $RC
if [ "$geom" != "" ]; then
w=`echo "$geom" | sed -e 's/[ xX].*//' -e 's/[^0-9]*//g' `
h=`echo "$geom" | sed -e 's/.*[ xX]//' -e 's/[^0-9]*//g' `
if [ "0$w" -ge 200 ]; then WIDTH=$w; fi
if [ "0$h" -ge 200 ]; then HEIGHT=$h; fi
fi
#
# Process the options
#
DEBUG=0
AVDEBUG=
unset OPTIND
while getopts "rw:h:p:u:D:h?" opt
do
case $opt in
h) HEIGHT="$OPTARG";;
w) WIDTH="$OPTARG";;
u) touch $RC; USERNAME="$OPTARG";;
p) touch $RC; PASSWORD="$OPTARG";;
r) touch $RC;; # refresh
D) DEBUG="$OPTARG"; AVDEBUG="-D$OPTARG";;
h|\?) usage;;
esac
done
shift `expr $OPTIND - 1`
#
# Authenticate and get the livecharts applet
#
get_applet() {
echo -e "$USERNAME\n$PASSWORD" | linuxtrade.auth livecharts.com |
(
read encpassword
read appletfile
sed -n '/<applet/,/<\/applet/p' < $appletfile > $LT/$APPLET
)
}
#
# If the rc file had changed, or the applet launch page is older than
# 1 day, then get a new copy of the applet launch page
#
touch -d yesterday $YEST
if [ $DEBUG -gt 0 ]; then
rm -f $LT/$APPLET
fi
if [ ! -s $LT/$APPLET -o $RC -nt $LT/$APPLET -o $LT/$APPLET -ot $YEST ]; then
get_applet
fi
#
# For each symbol on the command line, fire up a chart
#
cd $LT || exit 1
>lc.log
((i=0))
for sym in "$@"
do
#
# convert canonical index names to Lycos index names
#
case "$sym" in
'$DJI') sym='$INDU';;
'$DJT') sym='$TRAN';;
'$DJU') sym="$sym";;
'$COMP') sym='$COMPX';;
'$TRIN') sym='$TRIN';;
'$TICK') sym='$TICK';;
'$TRINQ') sym='$TRINQ';;
'$'*) sym="$sym.x";;
esac
sed < $APPLET > lc.tmp.$i \
-e "/SymbolChange/d" \
-e "s/SYMBOL.*/SYMBOL\" VALUE=\"$sym$lcopts\">/" \
-e "s/width=\"[^\"]*\"/width=\"$WIDTH\"/" \
-e "s/height=\"[^\"]*\"/height=\"$HEIGHT\"/"
linuxtrade.av $AVDEBUG "v1 moz v2" lc.tmp.$i >>lc.log 2>&1 &
((++i))
done
|