: ########################################################################## # Title : synonym - show synonyms for words # Author : Heiner Steven # Date : 1999-12-09 # Requires : geturl, striphtml, urlencode # Category : WWW # SCCS-Id. : @(#) synonym 1.2 03/02/07 ########################################################################## # Description # ########################################################################## PN=`basename "$0"` # Program name VER='1.2' POSTURL=http://www.m-w.com/cgi-bin/thesaurus Usage () { echo >&2 "$PN - show synonyms for words, $VER usage: $PN word [word ...] Uses the thesaurus at $POSTURL" exit 1 } Msg () { for MsgLine do echo "$PN: $MsgLine" >&2 done } Fatal () { Msg "$@"; exit 1; } assertdata () { egrep . || Msg "$@" } while getopts :h opt do case "$opt" in # your flags here h) Usage;; \?) Usage;; esac done shift `expr $OPTIND - 1` for word do encoded=`echo "$word" | urlencode` postline="book=Thesaurus&va=$encoded" echo "$postline" | geturl -p "$POSTURL" | assertdata "No data; URL correct?" | egrep '^(Function:|Text:)[ ]' | striphtml | cut -d: -f2- | grep -v '^[ ]*$' | sed 's:^[ ]*::' | { read wordtype echo "$word [$wordtype]:" cat } done