Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

(very silly) BOFH::Easy (instantiated in Net::Telnet)

by arturo (Vicar)
on May 14, 2001 at 18:23 UTC ( #80208=snippet: print w/ replies, xml ) Need Help??

Description: Queries the BOfH excuse server and returns an excuse. Reference: BOFH::Easy
#/usr/bin/perl

use strict;
use Net::Telnet;

print get_excuse(), "\n";

sub get_excuse {

        my $t = Net::Telnet->new(Host=>"bofh.jive.org",
                        Port=>666);
        while (my $line = $t->getline()) {
                next unless $line =~/Your excuse is: (.*)/;
                $t->close();
                return ucfirst $1;
        }
}
Comment on (very silly) BOFH::Easy (instantiated in Net::Telnet)
Download Code
Don't use Net::Telnet when IO::Socket::INET will do!
by merlyn (Sage) on May 14, 2001 at 18:54 UTC
    No need to invoke all that very heavy and possibly not installed Net::Telnet stuff. Just open the socket!
    #!/usr/bin/perl use strict; use IO::Socket::INET; my $c = IO::Socket::INET->new("bofh.jive.org:666") or die "connect: $@ +"; while (<$c>) { next unless /Your excuse is: (.*)/; print ucfirst $1, "\n"; exit; }
    Use Net::Telnet when there'll be terminal-like interaction with prompts and telnet protocol things. If it's just a socket, use the socket code!

    -- Randal L. Schwartz, Perl hacker

Re: (very silly) BOFH::Easy (instantiated in Net::Telnet)
by oakbox (Chaplain) on May 21, 2002 at 13:17 UTC
    NOTE:

    Just for funsies, I slipped this snippet into my former company's error handler CGI. (a simple CGI that caught ErrorDocument redirects from Apache, then printed an appropriate HTML message based on the code).
    On top of the 'real' message, I put in the output of this snippet. I ran it 30 or 40 times, funny, not too risque for my boss. No problemo.
    2 months later, I am called by the secretary asking why our web site is saying that she has sex with the boss's 8 year old son. There, in living HTML was a BOFH message on her screen.

    JUST IN CASE you were thinking about putting this in a 'real' place. Don't :)
    -oakbox

Back to Snippets Section

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: snippet [id://80208]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (9)
As of 2014-10-23 08:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (125 votes), past polls