If someone really intends running this script on some of her documents, please tar-gzip all the dictionary.com meanings and send it to me. I don't have a good Net connection. If your tarball is bigger than 80kb, upload it somewhere and send me the link. Tnx.
Manish Jethani
-------- getdict.sh -------- #!/bin/bash
######################################################################## # Script to fetch meanings of all words appearing in one or more files # of type "English text". Meanings are fetched from dictionary.com and # stored in HTML files of the same name as the word. The /meaning/ # files are stored in the $SPOOL_DIR (or whatever you want to call it). # # Words are picked up from files whose names you pass as command line # arguments. If a file is not an "English text" type file, it is # ignored. # # Dependencies: # file - for determining file type. # egrep - for doing pattern match on word. # wget - for fetching the meanings of words from dictionary.com. # # Before running, set $SPOOL_DIR and $WGET_LOGFILE. You can set # $WGET_LOGFILE to /dev/stdout to get output on console. # # e.g. ./getdict.sh ~/mbox # # Disclaimer: I'm not responsible if your computer crashes because of # this program. In fact, I'm very irresponsible, by nature. And I # don't know how to write shell scripts. # # License: Feel free to modify and distribute this script without my # permission. Just don't tell anyone that I wrote the original version. # # Bugs: I've just tested this on my home box (called 'moose') that runs # RedHat Linux 6.2. No bugs. :) Find and fix yourself. # # Copyleft (:P) 2001 Manish Jethani. All Rights Reversed. ########################################################################
# directory where /meaning/ files will be stored SPOOL_DIR=`pwd`/spool
# append logfile for wget WGET_LOGFILE=`pwd`/wget.log
# all files in $@ for file in $@; do # if $file is of type "English text" if file -bn $file | egrep -sq '^English text$'; then # each word in the $file for word in `cat $file`; do # if $word is alphanumeric if echo -n $word | egrep -sq '^[A-Za-z0-9]+$'; then meaning_file=$SPOOL_DIR/$word.html # if $meaning_file does not exist for $word if [ ! -f $meaning_file ]; then # create $meaning_file for $word echo -n "Fetching meaning of "$word" ... " wget -O$meaning_file -a$WGET_LOGFILE \ "http://www.dictionary.com/cgi-bin/dict.pl?term=$word" \ && echo "Done." \ || rm -f $meaning_file && echo "FAILED!" else echo "Meaning of "$word" already there." fi fi done else echo "Skipping $file - not an English text file." fi done