here is
THCB.pl. It is a candified "viewer" for telneting into the ChatterBox which does away with line endings but adds some color, a timer, and a log.
I say "viewer" because this can log you in and greet the CB if you enter a valid username and password. Otherwise, it will start telnet anyway and you can watch in anonymity.
My Question: THCB uses IPC w/autoflush because i would like to somehow pipe STDIN->TNOUT but can't figure out how to do that without interrupting the while loop.
#!/usr/bin/perl
use warnings;
use strict;
use Term::ANSIColor;
use IO::Handle;
use IPC::Open2;
$|=1;
print "User: ";
my $User=<>;
print "Pass: ";
my $Pass=<>;
open2(*TNIN, *TNOUT, "telnet desert-island.dynodns.net 4040");
TNOUT->autoflush(1);
open(LOG, ">THCB.log");
LOG->autoflush(1);
print TNOUT "auth ]$User [ $Pass";
my @c=("red","green","yellow","magenta");
my $n=0;
alarm 120; my $m=2;
while (<TNIN>) {
$SIG{ALRM}=sub{rearm()};
print LOG "$_";
if ($_ eq "Found you!\n") {print TNOUT "<i>exhaling...</i>\n"}
my @line = split / /; my $bit = shift @line; chomp @line;
if ($bit =~ /:$/) {
print color("blue on_cyan"), "$bit";
print color("reset");
}
else {print color("$c[$n]"), "$bit "}
print color("$c[$n]"), "@line ";
if ($n eq 3) {$n=0}
else {$n++}
}
sub rearm {
print color("white on_red"), "$m"; print "m";
print color("reset");
alarm 120; $m++; $m++;
}
NOTE: THCB does not yet log you out because you can't log out through telnet. You can log in repeatedly, but i recommend against this; eventually im2 sends little scoldings back.
Update: THCB is probably a *nix event
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.