Skip navigation.
Home
Your source for Perl tips, howto's, faq and tutorials
( categories: )

Hi all. New to Perl, but I like it.
I'm trying to make a server for my Android to control X10 home automation.
So far the Android is connecting with the server.
I need to send a command C:\Program Files (x86)\Common Files\X10\Common\ahcmd.exe sendplc a1 on.
A and 1 need to be set to a variable. A might be B or 1 could be 5 etc.
ON could be OFF or DIM or Bright.
Here's what I have so far:

use IO::Socket;
$local = IO::Socket::INET->new(
Proto => 'tcp',
LocalAddr => '192.168.1.104:5200
) or die "$!";
$local->listen();
$local->autoflush(1);
my $addr;
while ($addr = $local->accept() ) {
print "Connected from: ", $addr->peerhost();
print " Port: ", $addr->peerport(), "\n";
my $result;
while (<$addr>)
{
print "Received: $_";
print $addr $_;
print $path $_;
$result += $_;
close $addr;
}
chomp;

if (m/^end/gi) {
my $send = "result=$result";
print $addr "$send\n";
print "Result: $send\n";
}
print "Closed connection until next command\n";

close $addr;
}
Is there hope?