Subscribe
Jan 21 2008
Technical Support for Life PDF Print E-mail
Monday, 21 January 2008

I've been spending lots and lots of time feeding my cat. Approximately 1/3 of my life actually. He has an esophageal tube inserted into an incision in his neck and secured with sutures. Every three hours, I feed him for 1 hour. Last night, I missed two feedings. I guess the alarm clock has been sounding too much like the alarm clock and I've ignored it. That's a problem. The treatment for feline hepatic lipidosis is a large volume of food in a short amount of time. The prescription calls for 240ml of an antioxidant and development food, plus 200ml of water and a host of meds and supplements every day. The most I can inject into his feeding tube at any one time is around 5ml or he'll vomit.

For the sake of the cat's survival, I decided this afternoon that I needed some help staying focused and efficient in the feeding. I run Ubuntu Feisty on my desktop computer and I have a bunch of tools at my disposal. Never having considered myself a programmer, but having some experience in administration, I went for a comfortable bash script.

I used:

  • bash & the GNU bash utils
  • festival - the text-to-speech engine
  • lame - the free mp3 encoder
  • mpg123 - a high performance mpeg decoder
  • beep - a program that beeps
  • at - the nice little scheduler

Basically, it works like this:

At some time, the computer speaks:

"It's [whatevah time]. And it's time to feed the kitty" (think "mike", a highly synthetic and unnatural sounding voice with a little robotish wobble).

Thirty seconds pass and the message is repeated. This is loud enough to be annoying.

You get up out of bed, rub your eyes, look at the clock. Groan. Walk over to the computer, respond "1" to the on screen prompt "Are you here?".

The script proceeds to ask you what your name is, how many mLs of food and what meds and supplement are included in this little treatment. It then determines how long it will take you to administer that amount of food, tells you how long you're in for, and asks you to respond when ready. All of this information is written to a log file.

When you say go, old old school videogamey beeps sound at 1000Hz 2000Hz and 1500Hz. mike again speaks:

"Please give Snowball 5 milliliters of fresh water now"

More beeps follow. You do as instructed. 4 minutes later, the food begins.

"Please feed Snowball 5 milliliters of food, slowly."

This repeats every 5 minutes until all of the food is gone. Following this is another request for water to flush the tube. The terminal asks to report any problems that were encountered during the feeding.

For his finale, mike offers even more help:

"Please tell me what time you need to start next."

Using 'at', the system schedules a time to restart the script and wake you again, just a little too early to allow you to hit rem again before getting up for work.

Here's the code!

#!/bin/bash
 
 
#Set the volume using my "normal" script
/home/sley/bin/normal
 
 
#Set the logfile
log=/home/sley/snowballfeedinglog
 
clear
msg=$RANDOM
cd /tmp
 
#Init a var to determine whether or not Steve is awake.
present=0
 
while [ $present -lt 1 ]
do 
#Say what time it is. Repeat while presence is something less than one
echo "Its `date +%I`:`date +%M`. And its time to feed the kitty"
echo "Its `date +%I` `date +%M`. And its time to feed the kitty" > /tmp/$msg.txt
cat /tmp/$msg.txt | text2wave -o /tmp/$msg.wav
lame --quiet /tmp/$msg.wav /tmp/$msg.mp3
mpg123 /tmp/$msg.mp3 2&>1 /dev/null
rm /tmp/$msg.*
read -t 30 -p "Are you here? [Type 1]: " present 
done
#Get info and log
read -p "Please type your name: " name
read -p "How much food does Snowball eat now in milliliters?: " milliliters
read -p "Are you giving the nausea medicine? [y/n]: " naus
read -p "Are you giving the Amoxidrop? [y/n]: " amox
read -p "Are you giving the Vitamin solution? [y/n]: " vita
read -p "Are you giving the Baytril? [y/n]: " bay
read -p "Are you giving the L-Carnatine? [y/n]: " lcarn
 
 
echo "#########################################" >> $log
echo "At `date`, $name said they are feeding Snowball $milliliters milliliters of food" >>$log
echo "Medicines and Supplements:" >>$log
echo "Nausea: $naus" >>$log
echo "Amoxidrop: $amox" >>$log
echo "Vitamin: $vita" >>$log
echo "Baytril: $bay" >>$log
echo "L-Carnatine: $lcarn" >>$log
echo "........................................." >> $log
 
 
#Figure out how long this will take.
echo "#########################################"
reps=$(( $milliliters / 5 ))
echo That is $reps Reps 
 
duration=$((($reps*4)+8))
echo "You will be finished in $duration minutes"
echo "#########################################"
 
read -p "Press Enter When You Are Ready" ready
 
echo "Ready and starting at `date`." >>$log
echo "Ready and starting at `date`."
#Request a tube flush, wait 4 mins.
beep -f 1000 -n -f 2000 -n -f 2500 -n -f 2000 -n -f 1000 -n -f 2000 -n -f 2500 -n -f 2000 -n -f 1000 -n -f 2000 -n -f 2500 -n -f 500
echo "Please give Snowball 5 milliliters of fresh water."
mpg123 --quiet /home/sley/waternow.mp3 >/dev/null
sleep 240
 
 
while [ $reps  -gt 0 ]
do
#Request a feeding. Wait 4 minutes. Repeat until the food should be gone.
beep -f 1000 -n -f 2000 -n -f 1500 -n -f 1000 -n -f 2000 -n -f 1500 -n -f 1000 -n -f 2000 -n -f 1500 -n -f 1000 -n -f 2000 -n -f 1500
mpg123  --quiet /home/sley/feednow.mp3
beep -f 1000 -n -f 2000 -n -f 1500 -n -f 1000 -n -f 2000 -n -f 1500
 
sleep 240
reps=$(( $reps - 1 ))
echo "$reps left"
echo "........................................."
done
sleep 240
 
#Request more water.
beep -f 1000 -n -f 2000 -n -f 2500 -n -f 2000 -n -f 1000 -n -f 2000 -n -f 2500 -n -f 2000 -n -f 1000 -n -f 2000 -n -f 2500 -n -f 500
mpg123 /home/sley/waternow.mp3
beep -f 1000 -n -f 2000 -n -f 1500 -n -f 1000 -n -f 2000 -n -f 1500 -n -f 1000 -n -f 2000 -n -f 1500 -n -f 1000 -n -f 2000 -n -f 1500
 
read -p "Press enter when everything is done." done
echo "At `date`, $name reported that the feeding was complete" >>$log
 
#Log any problems.
echo " Please note any problems that you had during the process"
read problems 
echo $problems >> $log
echo "">> $log
msg=$RANDOM
cd /tmp
echo "Please tell me what time you need to start next" > /tmp/$msg.txt
echo "Please tell me what time you need to start next [HH:MM]"
cat /tmp/$msg.txt | text2wave -o /tmp/$msg.wav
lame --quiet /tmp/$msg.wav /tmp/$msg.mp3
mpg123 /tmp/$msg.mp3 2&>1 /dev/null
 
 
#Find out what time we need to start next and schedule with "at"
read next
at -f /home/sley/feedingforat.sh $next
echo "OK, I'll remind you at $next"
echo "Next Feeding Scheduled for $next" >>$log
 
echo "#########################################" >> $log

comments...

leave a comment
name
website
comment title
3000 character limit.
Security Image
web spam is a pain, please help me deal with it
by typing these letters in the box.