In the dungeon a bored geek bent over his simmering workstation.
"Now there I add bit of XML" he thought aloud. "And few left over chunks of useless commands".
**PUFF**
hmm, what's this. Enlighten me fellows.
Cheers
--arky
#!/bin/sh # # SCRIPT: cow-words.sh # AUTHOR: Rakesh 'arky' Ambati (http://www.linuxgazette.com/blog/4864) # DATE: 17 January 2005 # VERSION: you_must_be_kidding # # CREDITS: I Thank Karma_Police for the 'cow file randomizer code' # # PURPOSE: Retrieves the Dictionary.com 'Word of the Day" RSS Feed and # a random character teaches them. # # DEPENDS: 'xmlstarlet' http://xmlstr.sourceforge.net # 'cowsay' http://www.nog.net/~tony/warez/cowsay.shtml # Both are available packages in Debian (Sid) repository. # To install them just type 'apt-get install xmlstarlet cowsay' # # # set -x # Uncomment this for debugging. # # ############################################################################## # Use 'cowsay -l' to the full list of cow files in your system # # (Sorry fellas I removed possible offensive 'sodomized*, head-in,telebears, # # kiss' cow files # ##############################################################################
cows=(apt beavis.zen bong bud-frogs bunny cheese cower daemon default dragon dragon-and-cow elephant elephant-in-snake eyes flaming-sheep ghostbusters hellokitty kitty koala kosh luke-koala mech-and-cow meow milk moofasa moose mutilated ren satanic sheep skeleton small stegosaurus stimpy supermilker surgery three-eyes turkey turtle tux udder vader vader-koala www)
random=RANDOM%44
############################################################# ## Get the XML feed and do the selection ## #############################################################
/usr/bin/xmlstarlet sel --net -t -m "/rss/channel/item/description" -v "." "http://dictionary.reference.com/wordoftheday/wotd.rss" | /usr/bin/cowsay -n -f ${cows[random]}
# End of the script
Rakesh 'arky' Ambati wrote:
In the dungeon a bored geek bent over his simmering workstation.
"Now there I add bit of XML" he thought aloud. "And few left over chunks of useless commands".
Funneeey! But there's no AJAX in this! It isn't Web 2.0-ready yet! :D
Nice hack however, Arky. Wish I too was bored like you! ;)
Sajith.
--- Sajith T S sajith@gmail.com wrote:
Funneeey! But there's no AJAX in this! It isn't Web 2.0-ready yet! :D
Yeah right !!
As am not a programmer I like to avoid writing code if I can.The simplest approach I adopted is .... (am still looking for even simple way to do this)
shell(bash/ksh) -> xmlstarlet -> libxml2/libxslt (environment) (toolset) (libraries)
Perhaps a more experienced shell hacker would have done it using sed/ed with regex on shell itself. Of course, this approach is text filtering without any semantic parsing.
Nice hack however, Arky. Wish I too was bored like you! ;)
Thanks Sajith, I hoped that perhaps with infusion bit of dirty hacks we can have more interaction at FSUG-Blr.
Is it working ?
--arky
Rakesh 'arky' Ambati wrote:
Thanks Sajith, I hoped that perhaps with infusion bit of dirty hacks we can have more interaction at FSUG-Blr.
Is it working ?
The interaction part is working for me as you can see :)
Oh the script did work. There was no **PUFF** as you said. I was kinda hoping to see **PUFF** by shell script. Disappointed.
Well, I don't use Debian these days (yeah, sacrilege, I know.) Had to download an xmlstarlet rpm (sacrilege again!) In the rpm, the binary is named simply "xml." I had cowsay in /usr/local/, and the script was formatted weirdly by your email client, but these things are minor :)
And, yeah, you need to correct the xmlstarlet URL in the script.
Sajith.
--- Sajith T S sajith@gmail.com wrote:
Is it working ?
The interaction part is working for me as you can see :)
Oh the script did work. There was no **PUFF** as you said. I was kinda hoping to see **PUFF** by shell script. Disappointed.
LOL
<arky dons mexican mustaches and thick spanish accent>
A thousand pardons senor' , but you need wear thick glasses like me.Perhaps you can grab the soda bottle from freezer, and look thro it then you will notice the **PUFF**.
You understand the work done by xmlstarlet(or xml) '-t' template '-m' match then you get what I meant by **PUFF** (esp if you have to write any other language. )
Well, I don't use Debian these days (yeah, sacrilege, I know.) Had to download an xmlstarlet rpm (sacrilege again!)
Well, as long as its gnu/Linux powered by GPL then nothing matters.
In the rpm, the binary is named simply "xml." I had cowsay in /usr/local/,
Yes, everywhere the its called 'xml' but only in gnu/Debian packaging it was changed to 'xmlstarlet' following the conventions. And if you have a number of xml parsers and tools named 'xmlto', 'xml2' it will be a chaos.
But anyway all of 'em are complied against libxml2 (xmlsoft.org) so there still is sanity.
And regarding the question correct filepaths,the original hack (see my blog posts of 16 Jan) was just a single lined alias.
My script doesn't do any of the checks, coz 'Garbage In Garbage Out' style of my coding. (Nay, am just lazy).
and the script was formatted weirdly by your email client, but these things are minor :)
Sorry about the email client, bear with me till I can a new machine.
Lately as cricket fever was raging thro india, I use similar method to get the latest scores shall post it the blog later in the night.
Cheers
--arky
Rakesh 'arky' Ambati wrote:
Lately as cricket fever was raging thro india, I use similar method to get the latest scores shall post it the blog later in the night.
Well, I am not a shell script kidi33 like Arkie "PUFF" Ambati, but I have this much in my ~/.profile:
if [ -x /usr/bin/fortune -a -x /usr/local/bin/cowsay ] ; then /usr/bin/fortune -s | /usr/local/bin/cowsay -f moose fi
Nothing like an ASCII avatar uttering words of profanity of profoundity each time you fire up a shell :) (I know, height of silliness and all that, yes, but who have any delusion of grandeur?)
Sajith.
--- Sajith T S sajith@gmail.com wrote:
Well, I am not a shell script kidi33 like Arkie "PUFF" Ambati,
ROFL
Nothing like an ASCII avatar uttering words of profanity of profoundity each time you fire up a shell :) (I know, height of silliness and all that, yes, but who have any delusion of grandeur?)
Well spoken sir, ;oP
Cheers
--arky