Hi. I'm not any kind of bash afficianado: I can at least handle some of the basics, though. Recently I found some cool functions that did look pretty cool. The link to the site where they're described is
http://www.novell.com/coolsolutions/tools/18639.html . Especially the translate, define, and weather entries look useful. Problem is, that entry is dated enough that the functions no longer work. Even more of a problem is that these functions are complex enough that I can't really puzzle out where they may be malfunctioning. I suppose it may be simply because of the way the URL's have changed in the intervening years. I assume members of this list who are a lot better versed in this than I am may be able to spot and fix the problems and make the functions work once again. Anyone willing to have a go at that?
Thanks,
James
PS Relevant functions included below for reference:
Code:
weather ()
{
declare -a WEATHERARRAY
WEATHERARRAY=( `lynx -dump "http://www.google.com/search?hl=en&lr=&client=firefox-a&rls=org.mozilla%3Aen-US%3Aofficial&q=weather+${1}&btnG=Search" | grep -A 5 -m 1 "Weather for"`)
echo ${WEATHERARRAY[@]}
}
Code:
translate ()
{
TRANSLATED=`lynx -dump "http://dictionary.reference.com/browse/${1}" | grep -i -m 1 -w "${2}:" | sed 's/^[ \t]*//;s/[ \t]*$//'`
if [[ ${#TRANSLATED} != 0 ]] ;then
echo "\"${1}\" in ${TRANSLATED}"
else
echo "Sorry, I can not translate \"${1}\" to ${2}"
fi
}
Code:
# Define a word - USAGE: define dog
define ()
{
lynx -dump "http://www.google.com/search?hl=en&q=define%3A+${1}&btnG=Google+Search" | grep -m 3 -w "*" | sed 's/;/ -/g' | cut -d- -f1 > /tmp/templookup.txt
if [[ -s /tmp/templookup.txt ]] ;then
until ! read response
do
echo "${response}"
done < /tmp/templookup.txt
else
echo "Sorry $USER, I can't find the term \"${1} \""
fi
rm -f /tmp/templookup.txt
}