Click My Light / Web Control 

Theory of operation & notes:

When a bit is toggled +5 volts DC appears on pin 2 of the parallel / printer port.  You'll need to compile a small binary light.c to toggle this bit.  (type 'make' , 'make install' to compile it).  A simple NPN transistor picks up the 5 volt signal and is used to switch a load carrying relay, see the schematic light.png.  The relay can be used to switch 120 volts AC to control a conventional light or whatever.

Running the program with argument 'light -o', turns the device attached to the parallel port on.
Running the program with argument 'light -f', turns the device attached to the parallel port off.

The complied light binary needs to be run as the user 'root' for necessary access to hardware ports.   The Linux apache webserver runs as group user 'apache' not 'root' for obvious security reasons.  So to accomplish web control we set up two services,  lighton and lightoff.  Another reason for the two services is to eliminate a constant looping script (imagine the CPU time) that would otherwise be needed to check the status of a web submitted request.

When an internal telnet connection is made to the respective ports, (8000 for on, and 8001 for off) the binary we complied is run as 'root', and thus allows us to control the hardware printer / parallel port.

The web front end is light.main.cgi, and it passes the user submitted on/off click request to light.cgi, which creates an internal telnet connection to ultimately control the light or device.