my_nihilist has asked for the wisdom of the Perl Monks concerning the following question:
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.
Update: THCB is probably a *nix event
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.
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.#!/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++; }
Update: THCB is probably a *nix event
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: bidirectional challange
by ikegami (Patriarch) on Mar 13, 2008 at 22:26 UTC | |
by ikegami (Patriarch) on Mar 14, 2008 at 04:30 UTC | |
Re: bidirectional challange
by halfcountplus (Hermit) on Mar 14, 2008 at 03:48 UTC | |
Re: bidirectional challange
by my_nihilist (Sexton) on Mar 14, 2008 at 14:25 UTC |
Back to
Seekers of Perl Wisdom