Uptime on getdave.com



08:33:57 up 5 days, 14:38, 11 users, load average: 0.15, 0.06, 0.01





This script [uptime.cgi]:


#!/usr/bin/perl

($PROGNAME = $0) =~ s|.*/||;

#########################
# Header
#########################
my $host = `hostname`;
print <<END_OF_HEADER;
Content-type: text/html

<body bgcolor=white>

<br><br><br><br>

<h1>Uptime on $host</h1>

<br><br>
<h3>
END_OF_HEADER

#########################
# Uptime
#########################
$|=1;
system("/usr/bin/uptime");

#########################
# Footer
#########################
print <<END_OF_FOOTER;
</h3>
<br><br><br>

<p><hr><p>

<pre>
This script [$PROGNAME]:

END_OF_FOOTER

#########################
# Self-printing
#########################
print "<font size=-1>\n";
open(ME,$0) || exit;
while(<ME>) {
  # Goofy tricks to make it print out properly.
  s/&lt;/{"&DONT"."BREAKlt;";}/eg;
  s/&gt;/{"&DONT"."BREAKgt;";}/eg;
  s/</&lt;/g;
  s/>/&gt;/g;
  s/DON[T]BREAK/<nobr>/g;
  print;
}
close(ME);