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
j...@gibson.org

--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to