Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Sep 28th, 2012  |  syntax: None  |  size: 1.85 KB  |  views: 1,249  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/usr/bin/perl
  2.  
  3. sub cmd_penis{
  4.     my($server, $witem) = @_;
  5.     # Each bar is 6 hours (21600 seconds)
  6.     my($up) = getuptime();
  7.     my($timestr) = gettimestr($up);
  8.     my($units) = "=" x int($up / 21600);
  9.     my($sys) = `uname`;
  10.     chomp($sys);
  11.     $sys =~ tr/a-z/A-Z/;
  12.     if($sys eq "LINUX") {
  13.         $sys = "LUNIX";
  14.     }
  15.     print("$sys System Penistime: (_(_)".$units."D~ ($timestr)\n");
  16. }
  17.  
  18. sub getuptime {
  19.     open(UPTIME, "uptime|");
  20.     chomp(my($up) = <UPTIME>);
  21.     close(UPTIME);
  22.     $up =~ s/.*up (.*), \d+ user.*/$1/;
  23.     my($secs) = 0;
  24.     if($up =~ /(\d+) days\,?/) {
  25.         $up =~ s/(\d+) days\,?//;
  26.         $secs += $1 * 24 * 60 * 60;
  27.     }
  28.     if($up =~ /(\d+) mins\,?/) {
  29.         $up =~ s/(\d+) mins\,//;
  30.         $secs += $1 * 60;
  31.     }
  32.     if($up =~ /(\d+):(\d+)/) {
  33.         $up =~ s/(\d+):(\d+)//;
  34.         $secs += $1 * 60 * 60;
  35.         $secs += $2 * 60;
  36.     }
  37.     return $secs;
  38. }
  39.  
  40. sub gettimestr {
  41.     my($up) = $_[0]; # Seconds of uptime
  42.     my(@tmp);
  43.     $tmp[5] = "";
  44.  
  45.     # Years
  46.     $tmp[4] = int($up/31536000);
  47.     if($tmp[4] > 0) {
  48.         $up -= $tmp[4]*31536000;
  49.         $tmp[5] .= "$tmp[4]y ";
  50.     }
  51.  
  52.     # Weeks
  53.     $tmp[3] = int($up/604800);
  54.     if($tmp[3] > 0) {
  55.         $up -= $tmp[3]*604800;
  56.         $tmp[5] .= "$tmp[3]w ";
  57.     }
  58.  
  59.     # Days
  60.     $tmp[2] = int($up/86400);
  61.     if($tmp[2] > 0) {
  62.         $up -= $tmp[2]*86400;
  63.         $tmp[5] .= "$tmp[2]d ";
  64.     }
  65.  
  66.     # Hours
  67.     $tmp[1] = int($up/3600);
  68.     if($tmp[1] > 0) {
  69.         $up -= $tmp[1]*3600;
  70.         $tmp[5] .= "$tmp[1]h ";
  71.     }
  72.  
  73.     # Minutes
  74.     $tmp[0] = int($up/60);
  75.     if($tmp[0] > 0) {
  76.         $up -= $tmp[0]*60;
  77.         $tmp[5] .= "$tmp[0]m ";
  78.     }
  79.  
  80.     # Seconds
  81.     if($up > 0) {
  82.         $tmp[5] .= "${up}s ";
  83.     }
  84.  
  85.     $up = $tmp[5];
  86.     $up =~ s/\s$//;
  87.     return($up);
  88. }
  89.  
  90. cmd_penis();