1: #!/usr/bin/perl -w 
   2: #PID Roulette - Staring Bob the Cow; by Ben Jacobs 2001
   3: 
   4: use ExtUtils::testlib;
   5: use Curses;
   6: 
   7: srand( time() ^ ($$ + ($$ << 15)) );
   8: 
   9: $ps = sprintf('ps -Ao "%%p %%c" |');
  10: open BLAH, $ps; 
  11: 
  12: chomp(@file = <BLAH>);
  13: close(BLAH);
  14: 
  15: shift(@file);
  16: $doober = @file;
  17: 
  18: $randomnum = rand($doober);
  19: 
  20: foreach $blah (@file) {
  21:     $i++;
  22:     ($pids[$i], $names[$i]) = $blah =~ m/\s+(\d+)\s+(\w+)/g;
  23: }
  24: 
  25: $last = @pids;
  26: $randomnum = rand($last);
  27: 
  28: print "PID Roulette\n";
  29: print "Staring Bob the Cow\n";
  30: 
  31: initscr();
  32: noecho();
  33: cbreak();
  34: 
  35: $cow[0][0] = "          (__)";
  36: $cow[0][1] = "    ______( oo";
  37: $cow[0][2] = "---|       \\_|";
  38: $cow[0][3] = "   |       |";
  39: $cow[0][4] = "  / _______ \\";
  40: $cow[0][5] = " / /       \\ \\";
  41: 
  42: $cow[2][0] = "          (__)";
  43: $cow[2][1] = "    ______( oo";
  44: $cow[2][2] = "---|       \\_|";
  45: $cow[2][3] = "   |       |";
  46: $cow[2][4] = "   \\   __  /";
  47: $cow[2][5] = "    \\ \\ / /";
  48: 
  49: $cow[1][0] = "          (__)";
  50: $cow[1][1] = "    ______( oo";
  51: $cow[1][2] = "---|       \\_|";
  52: $cow[1][3] = "   |       |";
  53: $cow[1][4] = "  / ______ |";
  54: $cow[1][5] = " / /     / /";
  55: 
  56: $cow[3][0] = "          (__)";
  57: $cow[3][1] = "    ______( oo";
  58: $cow[3][2] = "---|       \\_|";
  59: $cow[3][3] = "   |       |";
  60: $cow[3][4] = "    \\  ____ \\";
  61: $cow[3][5] = "     \\ \\   \\ \\";
  62: 
  63: $cow[4][0] = "(__)";
  64: $cow[4][1] = "oo )______";
  65: $cow[4][2] = "|_/       |---";
  66: $cow[4][3] = "  |       |";
  67: $cow[4][4] = "  |  ___  |";
  68: $cow[4][5] = "  | |   | |";
  69: 
  70: $cow[5][0] = "(__)";
  71: $cow[5][1] = "oo )______";
  72: $cow[5][2] = "|_/       |---";
  73: $cow[5][3] = " |        |___";
  74: $cow[5][4] = " |  __________";
  75: $cow[5][5] = " | |";
  76: 
  77: $cow[6][0] = " | |    | |";
  78: $cow[6][1] = " |  ----  |";
  79: $cow[6][2] = " _        |";
  80: $cow[6][3] = "| \\       |---";
  81: $cow[6][4] = "** )------";
  82: $cow[6][5] = "(--)";
  83: 
  84: for ( $j = 0; $j < 16; $j+=2) {
  85:     for ( $x = 0; $x < 4; $x++) {
  86: 	clear();
  87: 	for ($i = 0; $i < 6; $i++) {
  88: 	    addstr($i + 2, $j, $cow[$x][$i]);
  89: 	}
  90: 	addstr(0, 0, "PID Roulette - Staring Bob the Cow");
  91: 	addstr(5, 30, $pids[$randomnum]);
  92: 	addstr(10, 0, "Bob is now going to kill \"$names[$randomnum]\", who's pid is \"$pids[$randomnum]\"");
  93: 	refresh();
  94: 	select(undef, undef, undef, .1);
  95:     }
  96: }
  97: select(undef, undef, undef, 1.5);
  98: clear();
  99: addstr(5, 30, $pids[$randomnum]);
 100: for ($i = 0; $i < 6; $i++) {
 101:     addstr($i + 2, 16, $cow[4][$i]);
 102: }
 103: addstr(0, 0, "PID Roulette - Staring Bob the Cow");
 104: addstr(10, 0, "Bob is now going to kill \"$names[$randomnum]\", who's pid is $pids[$randomnum]");
 105: refresh();
 106: select(undef, undef, undef, 1.0);
 107: clear();
 108: if (kill 9, $pids[$randomnum]) {
 109:     kill 9, $pids[$randomnum];
 110:     addstr(5, 30, "*POP*");
 111:     for ($i = 0; $i < 6; $i++) {
 112: 	addstr($i + 2, 16, $cow[5][$i]);
 113:     }
 114:     addstr(10, 0, "mwhahahahahahaha!");
 115: } else {
 116:     addstr(5, 30, $pids[$randomnum]);
 117:     for ($i = 0; $i < 6; $i++) {
 118: 	addstr($i + 2, 16, $cow[6][$i]);
 119:     }
 120:     addstr(10, 0, "Awwwwww ... Bob couldn't kill that PID. You should be playing as root. :-(");
 121: }      
 122: addstr(0, 0, "PID Roulette - Staring Bob the Cow");
 123: refresh();
 124: select(undef, undef, undef, 5);
 125: 
 126: endwin();
 127: 
 128: print "\nThanks for playing PID Roulette with Bob the Cow.\n\n";

Replies are listed 'Best First'.
Re: PID Roulette
by malloc (Pilgrim) on Jun 29, 2001 at 21:57 UTC
    This is hillarious. It reminds me of a rumor that i heard, of a linux version of doom, where each monster represented a process, and killing the monsters actually kill -9'd the pid of said monster! ever hear of this? Anyway, very cool++
    -malloc
      /me greps through bookmarks
      It's not a rumah!
      It' kind of hard to use

      --
      perl -p -e "s/(?:\w);([st])/'\$1/mg"