Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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

In reply to bidirectional challange by my_nihilist

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (1)
As of 2024-04-25 03:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found