Well its been almost a year and a half since DigitalConvergance died. But its legacy was not forgotten for geeks all over the world got a neat gadget to hack (see cuecat). I have used one of my cuecats to connect my door to the web. First, I glued a barcode to the side of my door. Next, I propped the cuecat so that when the door swung by it would scan the barcode. Then I wrote this perl script which updates the webstite, incrementing the counter and adding a timestamp, when it gets the barcode information. To see live statistics point your browser to phrontist.org. Here is the code:
#!/usr/bin/perl
use strict;
my $i = 0;
my ($time,$html);
while (1) {
my $meow = <STDIN>;
open(TIME,"date|");
$time = <TIME>; # Get Time
close(TIME);
$i++;
open(WWW,">/usr/home/web/www/index.html") or die "File did not open!\
+n";
$html = <<CATTAIL;
<html>
<title>The Door Server</title>
<body bgcolor="#000000" alink="#ffffff" link="#ffffff" vlink="#ffffff"
+ text="#ffffff">
<center><table STYLE="border:solid; border-width:1px; border-color:#FF
+FFFF"><tr><td><h1>The Door Server</h1></td></tr></table></center>
<br>
<center>
<table STYLE="border:solid; border-width:1px; border-color:#FFFFFF">
<tr>
<td>
<center><pre>
My door has been connected to the 'net through a somewhat unconvention
+al use of a <A HREF="http://www.cuecatastrophe.com">CueCat</A>
barcode scanner. I have adhered a barcode to the lower corner of my do
+or and as it opens
and closes it swings by the barcode scanner which sends the barcode in
+formation to the
FreeBSD (version 4.6) machine it my room. Upon getting this signal a <
+A HREF="http://perlmonks.org">perl</A> script running
on the machine springs into action and updates this page for your view
+ing pleasure. Below
you can see live statistics, such as how many times my door has been o
+pened/closed and
when it was last opened/closed. Enjoy
</pre></center>
</td>
</tr>
</table>
</center>
<br>
<center>
<table STYLE="border:solid; border-width:1px; border-color:#FFFFFF">
<tr>
<td>
<pre>
<center><H1>Stats:</H1></center>
Door Openings/Closings : $i
Time Last Opened/Closed: $time
</pre>
</td>
</tr>
</table>
</center>
</body>
</html>
CATTAIL
print WWW "$html" or die "did not print\n";
close(WWW);
}
"Sanity is the playground of the unimaginative"
-Unknown
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|