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
"Sanity is the playground of the unimaginative" -Unknown
#!/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("http://url.org/goes/here"); $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 | |
by Reverend Phil (Pilgrim) on Nov 20, 2002 at 17:50 UTC | |
by shotgunefx (Parson) on Nov 21, 2002 at 00:51 UTC | |
Re: Das Email Blinkenlight
by crenz (Priest) on Nov 22, 2002 at 12:03 UTC | |
Mister House
by logan (Curate) on Nov 26, 2002 at 17:48 UTC |
Back to
Cool Uses for Perl