Pages

25 August 2011

Moles

Moles are dynamic content scripts run by a Gopher server This last week I have been experimenting with them a little bit.

My first mole

This first one was a little naive, just to get the gist of how moles work:

#!/bin/sh

/usr/pkg/bin/cal
You can imagine the output of this script...

My second mole

This is the original code of the script. I had to strip it down a bit for it to properly work. But I'm including here this version as a starting point for a future revision and improvement. (You're warned. This mole has flaws!!!)

 #!/bin/sh

 #This mole creates a digest of the main text content of my gopher site.

 cd ~/gopher

 if test -d ~/gopher/digest; then
  cd ~/gopher/digest
 else
  mkdir ~/gopher/digest
  cd ~/gopher/digest
 fi

 echo "This is a digest of the most important text content of the gopher
 version of chalsattack. It is automatically created by a script for
 the very lazy people, too lazy even to navigate the site. Enjoy." > at_a_glance.txt

 #TODO:Add suffix .txt to files to be able to use *.txt and skip silly steps -->

 cp ~/gopher/presentation ~/gopher/digest
 cp ~/gopher/chalsattack/about ~/gopher/digest
 cp ~/gopher/chalsattack/history ~/gopher/digest

 FILES="presentation
 about
 history"

 for i in $FILES
 do
 cat $i >> at_a_glance.txt
 done

 cat at_a_glance.txt



 #Notify me if the script is run

 MAD=mail@address.com #MAD short for Mail ADdress

 echo "Mole out of the hole!!!" > ~/gopher/digest/mole.txt
 echo $(date) >> ~/gopher/digest/mole.txt
 cat ~/gopher/digest/mole.txt | mutt -s "Automatically sent report" $MAD

 #Please turn off the lights and take the garbage out!!!
 #rm -r ~/gopher/digest > /dev/null 2>&1