Advertisement
ichase

weather.sh

Sep 29th, 2011
201
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.49 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. #
  4. # Grab weather data from weather.com and format it according to the given XSLT
  5. # Script written by boojit
  6. # Modified by Hellf[i]re
  7. # The orignal script and xslt can be downloaded from http://pondol.com/weather.tar.gz
  8.  
  9. # Usage:
  10. # ${execi 1800 /path/to/weather/weather.sh location}
  11. # Usage Example:
  12. # ${execi 1800 /home/user/weather/weather.sh 03833}
  13.  
  14. # your Location ID: use http://xoap.weather.com/search/search?where=[yourcity] to find it
  15. # U.S. users can just use their zip code; doubt that works for anyone else though (YMMV)
  16. LOCID=$"23454"
  17.  
  18. # s=standard units, m=metric units
  19. UNITS=m
  20.  
  21. # where this script and the XSLT lives
  22. RUNDIR=/home/ichase/scripts/weather
  23.  
  24. # there's probably other stuff besides CURL that will work for this, but i haven't
  25. # tried any others.
  26. # you can get curl at http://curl.haxx.se/
  27. CURLCMD=/usr/bin/curl
  28.  
  29. # get it at http://xmlsoft.org/XSLT/
  30. XSLTCMD=/usr/bin/xsltproc
  31.  
  32. # you probably don't need to modify anything below this point....
  33.  
  34. # CURL url. Use cc=* for current forecast or dayf=10 to get a multi-day forecast
  35. CURLURL="http://xoap.weather.com/weather/local/$LOCID?cc=*&unit=$UNITS&dayf=2"
  36.  
  37. # The XSLT to use when translating the response from weather.com
  38. # You can modify this xslt to your liking
  39. XSLT=$RUNDIR/weather.xslt
  40.  
  41. #filter (if you want to convert stuff to lower-case or upper case or something)
  42. #FILTER="|gawk '{print(tolower(\$0));}'"
  43.  
  44.  
  45. #####
  46. eval "$CURLCMD \"$CURLURL\" 2>/dev/null| $XSLTCMD $XSLT - $FILTER"
  47.  
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement