Source
xxxxxxxxxx
#!/usr/bin/env perl
use ;
use ;
use :: ;
use :: ;
my $host = '127.0.0.1';
my $port = 10051;
my $input = '-';
my $output = '-';
my $help = 0;
my %options =
(
'host|h=s' => \$host,
'port=i' => \$port,
'input=s' => \$input,
'output=s' => \$output,
'help' => \$help
);
%options) or die "Bad command-line arguments\n"; (
do { print "Usage: $0 -h <host> -p <port> -i <file> -o <file>\n"; exit } if $help;
my $socket = new :::: ( => $host, => $port, => 'tcp', => 1);
die "Could not connect to $host:$port: $!\n" unless $socket;
$socket-> (0);
open , $input;
my $send = do { local $/; <> };
my $length = length $send;
close ;
print $socket "ZBXD\1";
do { print $socket chr($length % 256); $length /= 256 } for 1..8;
print $socket $send;
$socket-> ();
open , "> $output";
print while <$socket>;
close ;
close $socket;