Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

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

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; } }

Replies are listed 'Best First'.
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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2024-04-24 08:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found