[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cobalt-users] OT: Showing uptime via web



> Cody Watkins <codyw@xxxxxxxxxxxxxxxxx> wrote:
> > I want to show the number of days my RaQ3 has been up for in a Perl Cgi
> > script. I found a script to call the following up:
> >
> > 6:58pm  up 43 days,  3:38,  1 user,  load average: 0.05, 0.05, 0.05
> >
> > Does anybody know how I can cut everything but the number of days out
via a
> > command I can put in the script?
>
> Since the output of 'uptime' is going to always be of the same format you
can
> use regular expressions to pull out what you need.
>
> --
> Steven Werby {steven-lists@xxxxxxxxxxxx}
>

Yep -- here's a quick example:

@_=split(" ",$uptime); # split the uptime on spaces
$updays=@_[2]; # The day data will always be in the same place in your
array.

Hope that helps....

Kyle Scholz