1
0
Fork 0
mirror of https://github.com/perlbot/perlbuut synced 2025-06-07 17:25:41 -04:00
perlbuut/bin/console
2009-12-05 00:02:04 -05:00

36 lines
650 B
Perl
Executable file

#!/usr/bin/perl
use strict;
use Term::ReadLine;
use IO::Socket::INET;
use Getopt::Std;
my %OPTS;
getopts( 'p:', \%OPTS );
my $connect_port = $OPTS{p} || 14401;
my $socket = IO::Socket::INET->new(
PeerHost => '127.0.0.1',
PeerPort => $connect_port,
ReuseAddr => 1,
Proto => 'tcp',
Type => SOCK_STREAM,
) or die "Failed to connect to localhost on $connect_port, try specifying a port with -p";
my $term = Term::ReadLine->new( "BB3 Console" );
my $prompt = "bb3> ";
while( defined( $_ = $term->readline($prompt) ) ) {
print $socket "$_\n";
my $output;
sysread $socket, $output, 4096;
$output =~ s/^CC: //;
print $output, "\n";
}