In alt.hackers, Big Bad Bob <BigBadBob-at-mrp3-dot-
...@testing.local> wrote:
> haven't posted in a while. thought I'd poke my head up and increase
> activity. Main reason, temporarily ran out of 'obhack' ideas.
So you use a bunch up at one time? :^)
I posted here about a week and half ago (message-id
<eli$1103232...@qz.little-neck.ny.us>), but I'm not sure if it ever made
it off-site. I didn't see it at google groups.
> obhack#3: use external IDE/ATA to USB 2.0 adaptor to wipe ancient hard
> drives before toss/recycle. (Also good for data recovery)
I take out and store my harddrives at least a year or so after I think
I'm done with them. Then I disassemble.
> obhack#4: using white LEDs instead of light bulbs in "lights up"
> decorative stuff (mini-fountain, fiber optic lamp). I think the devices
> were designed so the bulbs would burn out a lot, and they're usually
> hard to find special order bulbs.
I doubt the design considered the life of the bulb at all. I stocked up
on mini-christmas tree lights of the white LED variety last December for
some LED projects I have in mind.
ObHack:
I found myself from time to time wanting to run something after a
particular time and not wanting to trust an 'at' job to do it since
environment tends to be different in at, and for a one-off you don't
necessarily want to be that careful in checking those things. So:
"waituntil" (below) was written. Sample scenario: automatic updates
of foo are broken and I'm in the process of fixing it. But over the
weekend when I'm not working on it, let's have it update.
$ script fooupdate.out
SCRIPT> waituntil 20110402 1000; echo Saturday run ; fooupdate ; \
waituntil 20110403 1000; echo Sunday run ; fooupdate
Obhack the second:
$ alias script
script=PS1='"SCRIPT> " script'
$
Elijah
------
#!/bin/sh
# waituntil YYYYMMDD HHMM [ longwaitsecs [ shortwaitsecs ] ]
# Poor man's at(1). Put at the start of a script to delay remainder
# until a particular date and time. Does not require any date math
# intelligence from date(1) or other sources.
# Runs even on very plain unixes.
# targetdate=20091024
# targettime=0200
long=3600 # 60 minutes, in seconds
short=900 # 15 minutes, in seconds
usage () {
echo "waituntil: usage:"
echo " waituntil YYYYMMDD HHMM [ longwaitsecs [ shortwaitsecs ] ]"
echo "Stop processing until after date and time."
echo "Longwait defaults to one hour, and is used until the day is reached."
echo "Shortwait defaults to a quarter hour and is used until the time is reached"
echo "Bug: do not specify a time less than shortwait from midnight."
exit 2;
}
case "$1" in 20??[01]???) targetdate="$1" ;;
*) echo "$0: First arg not in YYYYMMDD format"
usage ;;
esac
case "$2" in [012]?[0-5]?) targettime="$2" ;;
*) echo "$0: Second arg not in HHMM format"
usage ;;
esac
case "$3" in [1-9]*) long="$3" ;; esac
case "$4" in [1-9]*) short="$4" ;; esac
setdate () {
date=`date +%Y%m%d`
time=`date +%H%M`
}
setdate
if expr $date \> $targetdate >/dev/null ; then
echo "Target date has passed: now $date, target $targetdate"
exit 1
fi
while expr $date \< $targetdate >/dev/null ; do
sleep $long
setdate
done
echo Reached target date
while expr $time \< $targettime >/dev/null ; do
sleep $short
setdate
done
exit