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