Jerry Baker wrote:
> 
> "William A. Rowe, Jr." wrote:
> >
> > Win version?  Protocol (http/tls/ssl?)
> 
> Windows 2000 Pro. HTTP.

Attached is the script, and here is the output it gives from the command
line:

D:\..\www\cgi-bin>uptime.pl
Content-type: text/html

7 days 9:7:48


-- 
Jerry Baker

PGP Key: http://www.jerrybaker.org/pgp.html

LAME MP3 Encoder Binaries: http://www.jerrybaker.org/lame/
Apache 2.0 Web server Installer: http://www.jerrybaker.org/apache/
#!C:\perl\bin\perl.exe -w


# uptime.pl is a simple Perl script designed to get information about
# how long your server has been up since the last reboot and output
# that information for use on a Web page. If you somehow ended up
# with this script, and it didn't come with psuptime.exe, you can get
# psuptime for free at
# http://www.sysinternals.com/ntw2k/freeware/psuptime.shtml


#####################################################################
#                          CONFIGURATION                            #
#####################################################################
# I need the name of your computer. This information is found under
# the Network item in the Control Panel.

$computer = "c1579545-a";

# I need the path to psuptime.exe. Remember to use double slashes
# here (e.g., C:\Windows should be C:\\Windows)

$pspath = "C:\\Program Files\\Utils\\psuptime.exe";

#####################################################################
@catchoutput = ();
@datakeeper = ();
@infostore = ();
$count = 0;



# Capture the input from executing the psuptime program
foreach (`\"$pspath\" $computer`) {
    push(@catchoutput, $_);
    }


# Go through the output we just captured line by line to find the
# line that begins with our computer's name. This will be the line
# with the information we want on it.
foreach (@catchoutput) {
    if ($_ =~ /^$computer.*/) {
        @datakeeper = split (/ /, $_);
        }
    }

# Go through all of the values that the program outputs and separate
# them so we can print them how we wish.
foreach (@datakeeper) {
    if ($_ =~ /^day/) {
        $_ = $datakeeper[$count - 1] . " days ";
        push(@infostore, $_);
        } elsif ($_ =~ /^hour/) {
        $_ = $datakeeper[$count - 1] . ":";
        push(@infostore, $_);
        } elsif ($_ =~ /^minute/) {
        $_ = $datakeeper[$count - 1] . ":";
        push(@infostore, $_);
        } elsif ($_ =~ /^second/) {
        $_ = $datakeeper[$count - 1];
        push(@infostore, $_);
        }
     else {}
    $count = $count + 1;
    }

print "Content-type: text/html\n\n";
foreach (@infostore) {
    print $_;
    }

Reply via email to