Uptime on getdave.com



09:15:24 up 10 days, 11:16, 7 users, load average: 0.02, 0.04, 0.07





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);