Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Das Email Blinkenlight

by beretboy (Chaplain)
on Nov 19, 2002 at 23:33 UTC ( [id://214303] : CUFP . print w/replies, xml ) Need Help??

Despite my dislike of X10's evil marketing plots I caved and ended up picking up some X10 modules and an X10 Firecracker. For those of you who haven't seen the ads (consider yourself lucky) these little devices allow you to control lights and such from you computer. With the help of the wonderful BottleRocket utility I hacked together two scripts which turn on a funky little ikea light when I have new mail. The first script checks to see if I have mail every minute or so and updates a website. The second script (which runs on my home machine) checks this site every now and then and turns the light on and off accoordingly. There are two scripts because my mail is on my hosting service's machine my lights are controlled by a machine in my house. Thus two scripts
#!/usr/bin/perl use strict; $/ = undef; while (1) { open(MAIL,"/var/mail/perlmonk"); my $mail = <MAIL>; close(MAIL); open(WEB,">/usr/home/perlmonk/public_html/mail"); if ($mail) { print WEB "MAIL: YES\n"; } else { print WEB "MAIL: NO\n"; } close(WEB); sleep(60); }

#!/usr/bin/perl use strict; use LWP::Simple qw( get ); while (1) { my $mail = get(""); $mail =~ /MAIL: (YES|NO)/; my $status = $1; if ($status eq "YES") { system("br a1 on"); } else { system("br a1 off"); } sleep(20); }

"Sanity is the playground of the unimaginative" -Unknown

Replies are listed 'Best First'.
Re: Das Email Blinkenlight
by shotgunefx (Parson) on Nov 20, 2002 at 04:46 UTC
    X10 technology is actually cool. It's their marketing that sucks. When there's a problem with any of my servers, I play a loud klaxon sound and have x10 turn on a red "police light" strobe to get my attention.


    "To be civilized is to deny one's nature."
      I may be completely off my rocker here, but I was under the impression that 'x10' was just a protocol name for interacting with objects through your power lines (somewhat limited to on/off, though I could be wrong on that). And the x10 advertising you're referring to sounds like those evil little pop-up ad cameras that have marked the boom of that annoying internet advertising trend. Perhaps they are 'x10 enabled' in some fashion, and are using that as their company/product name. *shrug* Anyone more versed in this? Am me confused, or is them are?

        x10 is a technology for signaling over power lines. There are x10 products that aren't made by X10 Ltd, but I do believe X10 Ltd (which I belive is has most of the patents on the technology. more info


        "To be civilized is to deny one's nature."
Re: Das Email Blinkenlight
by crenz (Priest) on Nov 22, 2002 at 12:03 UTC

    Nice idea. Here's two suggestions to reduce the load on your server:

    • 1. If someone sends you a couple mails with huge attachments, $mail = <MAIL> might end up reading a few hundred kilobytes of data! Use the -s operator to find out the file size, e.g. if (-s $file > 0) { print "YES"; }.
    • 2. Make it a CGI script that returns the data. This way, it will only be executed when your computer is on and checking for e-mail -- rather than all the time.

    fixed typo

Mister House
by logan (Curate) on Nov 26, 2002 at 17:48 UTC
    I found myself in the same dilemma. While X10's technology is kick-ass, their marketing department deserve to be shot, one and all. A few years ago, I found an article about home automation in The Perl Journal, and immediately bought a ton of X10 gear. A few months later, they launched their plague upon the internet, and I haven't bought anything from them since.

    If you really want to make your whole house jump, check out Mister House. It's a free perl application that allows you to control everything from your alarm clock to your window blinds using a web interface. It even has voice recognition and a text-to-speech module so you can interact with it just by talking. Just don't name it Hal.

    "What do I want? I'm an American. I want more."