shell script bug [was: capturing CBC Radio from an internet stream]

D. Hugh Redelmeier hugh-pmF8o41NoarQT0dZR+AlfA at public.gmane.org
Mon Apr 7 19:18:14 UTC 2008


| Date: Sun, 17 Feb 2008 02:09:21 -0500 (EST)
| From: D. Hugh Redelmeier <hugh-pmF8o41NoarQT0dZR+AlfA at public.gmane.org>

| Here's a shell script that I call GRAB1hrCBC1mms:

|     DATE=`date +%Y.%m.%d-%H.%M`
| 
|     mmsrip --delay=3600 --output=$DATE.wma mms://wm.cbc.ca/cbcr1-${CITY:-toronto}

I "improved" this, allowing the recording time to be overridden and a
description to be added to the resulting file's name:
    mmsrip --delay=${SECONDS:-3600} --output=${DATE}${DESCRIPTION:-}.wma \
	mms://wm.cbc.ca/cbcr1-${CITY:-toronto}

Simple and useful, eh?

Well, the result was that my partition slowly filled up and the
recording never terminated.  The first time, I thought it was a fluke.

It turns out that bash "owns" the variable SECONDS.  It is the number
of seconds since the shell was invoked.  mmsrip was probably seeing
--delay=0.

I hate reserved words.  I hate silently reserved words -- no warning
just bad behaviour.

The fix is simple.  I used DURATION instead.
--
The Toronto Linux Users Group.      Meetings: http://gtalug.org/
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://gtalug.org/wiki/Mailing_lists





More information about the Legacy mailing list