#!/usr/bin/env ruby # Script to extract images from the Hawking HNC230G # # Copyright (C) Tim Haynes # HNC230G{at}stirfried.vegetable.org.uk http://pig.sty.nu/ # # Modified to work as a cheesy CGI by Mikey Dickerson, # mikey@singingtree.com. See http://obstrepero.us/hacks/webcam.shtml # # Redistributable under the terms of the GNU Public License: see # # # Requires ruby # nopics=ARGV[1] || "1" nopics=nopics.to_i require 'socket' s=TCPSocket.new('cam1', 4321) nopics.times { |n| s.puts("0110") len=s.read(2).reverse.unpack("v")[0] 2.times {s.getc } jpeg=s.read(len) puts "Content-type: image/jpeg\n" puts "Pragma: no-cache\n" puts "\n" puts jpeg }