1: #!/usr/bin/perl
2:
3: # This script is a fun joke you can play on coworkers
4: # who leave their terminals unattended. It prints a
5: # fake shell prompt, and every time the victim presses
6: # a key, it outputs the next letter of the sentence you
7: # set at the top. At the end of the sentence, it prints
8: # a "command not found" error and gives them another fake
9: # prompt.
10: #
11: # For best results, add a line that runs this script to the
12: # end of the victim's .profile
13: #
14: # - Matt Carothers <matt@telepath.com>
15:
16: use strict;
17: use Term::ReadKey;
18:
19: $| = 1;
20:
21: # Change these around as necessary
22: my $sentence = 'My momma wears combat boots.';
23: my $prompt = 'bash-2.02$ ';
24: my $notfound = 'bash: command not found:';
25:
26: my $index = 0;
27: my $length = length($sentence);
28: (my $firstword = $sentence) =~ s/\s.*//;
29: my $key;
30:
31: # Switch terminal to raw mode
32: ReadMode "raw";
33:
34: # print a phony shell prompt
35: print "$prompt";
36: while (1)
37: {
38: # Wait for a key press
39: if ($key = ReadKey(-1))
40: {
41: # Exit on a ^D. Remove or change this for
42: # added cruelty.
43: last if ($key eq "\x04");
44:
45: # Print the next character of the sentence. Wrap
46: # around when the end of the sentence is reached.
47: print substr($sentence, $index++ % $length, 1);
48:
49: # At the end of the sentence, print a phony
50: # "command not found" error message
51: if (!($index % $length))
52: {
53: print "\n$notfound $firstword\n$prompt";
54: }
55: }
56: }
57:
58: # Put the terminal back the way it was
59: ReadMode "restore";
60: print "\n";
61:
62: # EOF
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Practical joke
by Falkkin (Chaplain) on Jan 25, 2001 at 06:20 UTC | |
by Fastolfe (Vicar) on Jan 25, 2001 at 10:47 UTC | |
|
(yakko: ignoreeof is evil) Re: Practical joke
by yakko (Friar) on Feb 03, 2001 at 11:11 UTC |