/ Published in: Perl

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
#!/usr/bin/perl # # Author : Keiran "Affix" Smith <Affix_at_Affix_dot_me> # Website: http://keiran-smith.net # Description : # Parse the output of the linux uptime command into easy to understand # readable text x Days y Hours z Minutes # UPDATES : # - December 19th 2010 # + Fixed a bug regarding minutes # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; version 2 of the License. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # Get and Parse System Uptime $days[3] =~ s/[0-9][0-9]:[0-9][0-9]/0/; if($days[3] < 1) { $uptime = $hrmins[0] . " Hours " . $hrmins[1] . " Minutes"; } else { $uptime1[1] =~ s/ //; if($hours[2] == 'users') { $uptime = $days[3] . " Minutes"; } else { $uptime = $days[3] . " Days " . $hrmins[0] . " Hours " . $hrmins[1] . " Minutes"; } }
URL: http://affix.me
Comments
