Scraping the barrel....
Some code snippets to play with:
#1
----------------------------------------------------------------
$ ./tlp
Threat level is: 1 LOW
#2
----------------------------------------------------------------
gwp:
$ ./gwp
Today Partly Cloudy / Wind 93°/71° 10 %
#3
---------------------------------------------------------------
ghp:
$ ./ghp
VIRGO (Aug. 23-Sept. 22). Pride of ownership applies to all of your possessions, and you'll take care that they sparkle, shine and really work. Tonight, you'll be reminded how much you cherish and need plenty of space to do your thing.
#1
----------------------------------------------------------------
Code:
#!/bin/sh # Determine the current U.S. Terrorist Threat Advisory level, and output it to # a serial device # # Written by Matt Mets in 2008 # Modified by Computothought in 2011 # This code is released into the public domain, attribution is appreciated #### Configuration Options ############################################## # Location of the threat alert level XML document SRC_URL="http://www.dhs.gov/dhspublic/getAdvisoryCondition" # Left for compatibility to original use of this code # Serial device to output the result to (not used at this time) # TTY_DEV="/dev/ttyS1" ######################################################################### # Retrieve the current threat level # We are expecting something like: # <?xml version="1.0" encoding="UTF-8" ?> # <THREAT_ADVISORY CONDITION="ELEVATED" /> ALERT_DOC=`wget ${SRC_URL} -q -O -` # Do some rudimentary parsing using regular expressions to isolate the current # threat level # TODO: can this be done in one pass? TMP=${ALERT_DOC#*CONDITION\=\"} ALERT_LEVEL=${TMP%\" *} # Convert the output into a serial command # (The current system expects just a number 1-5) case ${ALERT_LEVEL} in SEVERE) COMMAND=5 ;; HIGH) COMMAND=4 ;; ELEVATED) COMMAND=3 ;; GUARDED) COMMAND=2 ;; LOW) COMMAND=1 ;; esac # If a threat level was retrieved, output it to the device if [ -n ${COMMAND} ] then # Send the command to the serial port (-n supresses the newline character) echo -n "Threat level is: " echo ${COMMAND} ${ALERT_LEVEL} # > ${TTY_DEV} echo Threat level is: ${COMMAND} ${ALERT_LEVEL} > tl twidge update < tl exit 0 else exit 1 fi
Threat level is: 1 LOW
#2
----------------------------------------------------------------
gwp:
Code:
# Get today's weather ZIP=77331 elinks "http://www.weather.com/weather/print/$ZIP" > weather ; cat weather | grep Today
Today Partly Cloudy / Wind 93°/71° 10 %
#3
---------------------------------------------------------------
ghp:
Code:
# Get today's horoscope hsign="VIRGO" lynx -width 1000 -dump "http://www.creators.com/lifestylefeatures/horoscopes/horoscopes-by-holiday.html" > hscope ; cat hscope | grep $hsign
VIRGO (Aug. 23-Sept. 22). Pride of ownership applies to all of your possessions, and you'll take care that they sparkle, shine and really work. Tonight, you'll be reminded how much you cherish and need plenty of space to do your thing.
Total Comments 0