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
[email protected]

--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/


Reply via email to