On occasion I get an e-mail asking me about my live webcam. What model is it? Does it support FTP/SSH? How does it automatically upload to your site? And so on...

Some answers:

Model: Linksys WVC54GCA Wireless G Home Monitoring Camera
FTP/SSH support: Nope

Capturing Live Images

So how do I automate taking pictures with the thing? Well, a hidden feature to the camera is to navigate to the static picture site of the webcam. For my example, I use DNS to map my camera hostname garfunkel to its IP address. You may want to enter whatever IP your camera uses instead of garfunkel.
To grab a picture at any given time, use wget.
wget http://garfunkel/img/snapshot.cgi?size=3\&quality=1
-O webcam.jpg
If you have a UNIX-based or UNIX-like OS, you can schedule a cron job to grab this image as often as you like. I prefer capturing once every half hour, so I use this template:
*/30 * * * * /path/to/wget/script
Now, if you have your own web page, you can use ftp/sftp/scp to upload the picture to your server using one script.

Creating Time-Lapse Videos

If you can capture a picture once every minute, you can create a pretty neat time-lapse video every day. This can be accomplished using wget and ffmpeg. For my camera, I point it outside, so it's only worth capturing between certain hours, say 6am to 6pm. After 6pm, I will have created over 700 pictures. I can then use ffmpeg to stitch them together to form a short video on the day's weather. It's a little complicated to discuss every detail behind this, so I'll just post the bourne script I use.

hour=`date +%H`
captime=`date +%H%M`
img=`ls ${dirpath}*jpg | wc -l`;
expr=`expr 1 + $img`

	# File format will be Month.Day.Year.flv (flv for 
	# flash)
	date=`date +%m.%d.%y.flv`

	# ffmpeg reads in each image and incrementally
	# makes a flash video at 16 fps
	cd ${dirpath}
	ffmpeg -i %04d.jpg -r 16 ${dirpath}${date}

        # Cleanup, upload time-lapse to server and remove 
	# all jpg files
	# scp user@host:location
	# rm ${dirpath}*jpg

        # ffmpeg expects pictures in the format 0001.jpg ... 
	# 0001.jpg so we need to add a fluff of zeros to
	# make each pic 4 digits long

	if [ $expr -lt 10 ]

	elif [ $expr -lt 100 ]

	elif [ $expr -lt 1000 ]

        wget http://garfunkel/img/snapshot.cgi?size=3
\&quality=1 --output-document=${dirpath}${expr}.jpg

case "$hour" in
# Eliminate the hours of the day that are too dark to capture
# If it is 6:00pm (18), time to make a video
	if [ $captime -eq 1800 ]
# Every other hour is assumed to have light, so take a pic
You might want to change the dirpath variable to wherever you want to store the pictures. Finally, add a cron entry to run every minute:
* * * * * /path/to/timelapse/script
After 6pm, you will have an flv file. This is a flash file that can be played by various flash players for viewing on the web. You can change the file format to avi or mpg instead of flv if you just want to view it on your computer.

Sample video from my camera

posted by paulie
8:40 PST - December 14, 2009

Today I thought I broke the numpad on my keyboard; none of then numbers were working. Switching on and off the Num Lock key didn't work. However, anytime I hit a number and held the key down, the mouse cursor would move across the screen. By some sort of black magic, I found a secret keyboard combo to turn on Mouse control via keypad.

Solution to turn it off
System -> Preferences -> Assistive Technologies -> 
Keyboard Accessibility -> Mouse Keys

Uncheck 'Pointer can be controlled using the keypad'
I must admit, however, this can be a handy feature when working with a mouse-less machine.

posted by paulie
14:22 PST - December 9, 2009

If you try to delete a directory over NFS and get an error such as...
rm: cannot remove directory 'asdf/': File exists
... you will notice that conventional methods won't be good enough to remove it.
$ chmod -R 777 asdf/
$ rm -rf asdf/
$ rm: cannot remove directory 'asdf/': File exists
Usually there is a file like .nfs234B inside the directory than can be displayed with ls -la Removing this file only replaces it with another. There are two solutions: manually delete the file on the NFS server, or (if you don't have that type of access) kill its process.
$fuser -u asdf/.*
asdf/.:     9070c(user)
asdf/..:    28690c(user)   24845c(user)
asdf/.nfs934B:     9070tm(user)
9070 is the offending process. Kill it with fire.
$ kill -9 9070
Should be able to remove that directory now.

posted by paulie
2:12 PST - May 20, 2009

So you think your wireless link is slow, or your gigabit ethernet card is under performing. How can you tell? Here are two tools I use to test network throughput.


Created by Kai Uwe Rommel, it tests by sending and receiving packets of varying sizes and reports throughput in kilobytes per second.

  • x86
# wget
# ftp://ftp.sunfreeware.com/pub/freeware/intel/
# gzip -d netio-1.26-sol10-x86-local.gz
# pkgadd -d netio-1.26-sol10-x86-local
# wget
# ftp://ftp.sunfreeware.com/pub/freeware/sparc/
# gzip -d netio-1.26-sol10-sparc-local.gz
# pkgadd -d netio-1.26-sol10-sparc-local
  • Server-side
# netio -u -s
  • Client-side

Here are results on a 100Mbps link:
UDP connection established.
Packet size  1k bytes:  11913 KB/s  Tx, 11468 KB/s Rx.
Packet size  2k bytes:  11954 KB/s  Tx, 11509 KB/s Rx.
Packet size  4k bytes:  12274 KB/s  Tx, 11687 KB/s Rx.
Packet size  8k bytes:  12284 KB/s  Tx, 11697 KB/s Rx.
Packet size 16k bytes:  12292 KB/s  Tx, 11702 KB/s Rx.
Packet size 32k bytes:  12348 KB/s  Tx, 11714 KB/s Rx.
Sending and receiving hovered around 11-12MB/s which is on par with 100Mbps.


Created by Rick Jones and discovers the maximum throughput of a link, reporting in megabits per second.

# wget ftp://ftp.netperf.org/netperf/netperf-2.4.4.tar.gz
# tar zxvf netperf-2.4.4.tar.gz
# cd netperf-2.4.4
# export CFLAGS="-lsocket -lnsl -lkstat"
# ./configure
# make
# make install
  • Server-side
# netserver
  • Client-side

Here are results on a 100Mbps link:
Recv   Send    Send                          
Socket Socket  Message  Elapsed              
Size   Size    Size     Time     Throughput  
bytes  bytes   bytes    secs.    10^6bits/sec  

 49152  49152  49152    10.00      94.88

94.88 Mbps is the final result, not bad.

posted by paulie
6:35 PST - May 1, 2009

Blog Archive by Year

2018 2017 2016 2015 2014 2013 2012 2011 2010 2009