Front page | perl.beginners |
Postings from December 2010
Re: Linux Uptime
Thread Previous
|
Thread Next
From:
Jim Gibson
Date:
December 16, 2010 18:27
Subject:
Re: Linux Uptime
Message ID:
p06240800c93079b9de3f@[192.168.1.3]
At 7:32 PM -0600 12/16/10, Matt wrote:
>I have a perl script but I want to exit it if the uptime on the server
>is less then say an hour. Any idea how I would get uptime with perl?
On Unix:
my $uptime = qx(uptime);
Then parse $uptime with a regular expression, which may depend upon
what your version of uptime outputs :
if( $uptime =~ /up (\d+s+\w+)/ ) {
print "$1\n";
}
--
Jim Gibson
Jim@Gibson.org
Thread Previous
|
Thread Next