Debian Codegraph @

quote-fetch.sh

raw symbols SCIP
1 #!/bin/bash
2 # quote-fetch.sh: Download a stock quote.
3
4
5 E_NOPARAMS=86
6
7 if [ -z "$1" ] # Must specify a stock (symbol) to fetch.
8 then echo "Usage: `basename $0` stock-symbol"
9 exit $E_NOPARAMS
10 fi
11
12 stock_symbol=$1
13
14 file_suffix=.html
15 # Fetches an HTML file, so name it appropriately.
16 URL='http://finance.yahoo.com/q?s='
17 # Yahoo finance board, with stock query suffix.
18
19 # -----------------------------------------------------------
20 wget -O ${stock_symbol}${file_suffix} "${URL}${stock_symbol}"
21 # -----------------------------------------------------------
22
23
24 # To look up stuff on http://search.yahoo.com:
25 # -----------------------------------------------------------
26 # URL="http://search.yahoo.com/search?fr=ush-news&p=${query}"
27 # wget -O "$savefilename" "${URL}"
28 # -----------------------------------------------------------
29 # Saves a list of relevant URLs.
30
31 exit $?
32
33 # Exercises:
34 # ---------
35 #
36 # 1) Add a test to ensure the user running the script is on-line.
37 # (Hint: parse the output of 'ps -ax' for "ppp" or "connect."
38 #
39 # 2) Modify this script to fetch the local weather report,
40 #+ taking the user's zip code as an argument.