Linux Uptime

2010-12-16 Thread Matt
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? -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Linux Uptime

2010-12-16 Thread Sheppy R
http://search.cpan.org/~burak/Sys-Info-Base-0.73/lib/Sys/Info/OS.pm#uptime Sys::Info::OS has an uptime() method. On Thu, Dec 16, 2010 at 8:32 PM, Matt lm7...@gmail.com 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

Re: Linux Uptime

2010-12-16 Thread Jeff Peng
于 2010-12-17 9:32, Matt 写道: 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? $ cat /proc/uptime 4205976.64 4017280.59 The first column is the host's uptime seconds. Jeff. -- To unsubscribe, e-mail

Re: Linux Uptime

2010-12-16 Thread Jim Gibson
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

Re: Linux Uptime

2010-12-16 Thread Katie T
On Fri, Dec 17, 2010 at 2:25 AM, Jeff Peng jeffp...@gmx.net wrote: 于 2010-12-17 9:32, Matt 写道: 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? $ cat /proc/uptime 4205976.64 4017280.59 The first

Re: Linux Uptime

2010-12-16 Thread Katie T
On Fri, Dec 17, 2010 at 3:21 AM, Katie T ka...@coderstack.co.uk wrote: On Fri, Dec 17, 2010 at 2:25 AM, Jeff Peng jeffp...@gmx.net wrote: 于 2010-12-17 9:32, Matt 写道: 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

Re: Linux Uptime

2010-12-16 Thread Shawn H Corey
On 10-12-16 10:21 PM, Katie T wrote: /proc/uptime is a linux innovation I believe, other *nix variant may not have it (I don't think Solaris does). The /proc directory is a pseudo-directory that the kernel maintains. Every file in it is a pipe that can be read using regular file handles

Re: Linux Uptime

2010-12-16 Thread Jeff Peng
于 2010-12-17 11:29, Shawn H Corey 写道: Every file in it is a pipe that can be read using regular file handles. And I believe only Linux does this. Yep.Also the OP is asking exactly about linux. -- Jeff Peng jeffp...@gmx.net -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For

Re: Linux Uptime

2010-12-16 Thread Alan Haggai Alavi
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? Hi, You could use the distribution: Unix::Uptime (http://search.cpan.org/perldoc?Unix::Uptime) Example: use strict; use warnings; use

Re: Using ssh for uptime?

2002-12-11 Thread zentara
Net::SSH qw( sshopen3 ); my $user = bob; my $host = 10.10.10.10; my $cmd = uptime; sshopen3( $user\@$host, *WRITER, *READER, *ERROR, $cmd ); my $uptime = READER; chomp $uptime; print $uptime\n; something like that ought to so it... Also if you do use Net::SSH, you need to use key authorization

RE: Using ssh for uptime?

2002-12-10 Thread Mark-Nathaniel Weisman
[mailto:[EMAIL PROTECTED]] Sent: Monday, December 09, 2002 7:58 AM To: [EMAIL PROTECTED] Subject: Re: Using ssh for uptime? On Sun, 8 Dec 2002 23:14:36 -0900, [EMAIL PROTECTED] (Mark-Nathaniel Weisman) wrote: Mark, I've got the code you sent installed and working (or almost working anyway

RE: Using ssh for uptime?

2002-12-10 Thread chad kellerman
= uptime; sshopen3( $user\@$host, *WRITER, *READER, *ERROR, $cmd ); my $uptime = READER; chomp $uptime; print $uptime\n; something like that ought to so it... chad On Tue, 2002-12-10 at 11:44, Mark-Nathaniel Weisman wrote: My box does not seem to have the Net::SSH::Perl installed. How can I

RE: Using ssh for uptime?

2002-12-09 Thread Mark-Nathaniel Weisman
Mark, I've got the code you sent installed and working (or almost working anyway) snippet below: foreach my $rec (@machines) { ($host,$user,$pass,$sname) = split(/,/, $rec); open2(*RD_HD, *WR_FH, ssh -l $user $host $user/@$host uptime) || die cant fork child; print WR_FH

Re: Using ssh for uptime?

2002-12-09 Thread Mark Goland
Well whats not working ?? Mark - Original Message - From: Mark-Nathaniel Weisman [EMAIL PROTECTED] To: Mark Goland [EMAIL PROTECTED] Cc: perl [EMAIL PROTECTED] Sent: Monday, December 09, 2002 3:14 AM Subject: RE: Using ssh for uptime? Mark, I've got the code you sent installed

Re: Using ssh for uptime?

2002-12-09 Thread zentara
zentara.zentara.net); foreach my $host (@hosts){ my $cmd = /usr/bin/uptime; my $ssh = Net::SSH::Perl-new( $host, port = 22); $ssh-login($user,$password); my($out) = $ssh-cmd($cmd); my ($time,$uptime) = (split /\s+/,$out)[1,3]; chop $uptime; print $host has been up $uptime\n

Re: A little help with uptime.

2002-12-08 Thread zentara
(/,/, $rec); open (OUTFILE, records.txt) or die Error opening records.txt.$!,stopped; close(OUTFILE); open (OUTFILE, records.txt) or die Error opening records.txt.$!,stopped; print OUTFILE 'ssh -l $user $host uptime'; close(OUTFILE); }; Without the greater

RE: A little help with uptime using SSH.

2002-12-08 Thread Mark-Nathaniel Weisman
Below is the snippet of code that now returns incremental numbers to the array. I need to be able to pass the password to the connection to get the command to run. I'm not sure if I'm getting a shell out in the first place. However, this is what I'm trying to do. Get the uptime from other local

RE: Using ssh for uptime?

2002-12-08 Thread Mark-Nathaniel Weisman
This is the line that allowed me to capture a uptime value with Perl using ssh to the remote boxes. $uptime = system ssh -l $user $host uptime $pass; The return value is; 65280 for all boxes. Anyone have any idea why I'm not reading the real uptimes, instead I get the number

Re: Using ssh for uptime?

2002-12-08 Thread Mark Goland
system returns shell exit status - Original Message - From: Mark-Nathaniel Weisman [EMAIL PROTECTED] To: perl [EMAIL PROTECTED] Sent: Sunday, December 08, 2002 3:23 AM Subject: RE: Using ssh for uptime? This is the line that allowed me to capture a uptime value with Perl using ssh

A little help with uptime.

2002-12-07 Thread Mark-Nathaniel Weisman
records.txt.$!,stopped; close(OUTFILE); open (OUTFILE, records.txt) or die Error opening records.txt.$!,stopped; print OUTFILE 'ssh -l $user $host uptime'; close(OUTFILE); }; Without the greater than marks of course. Where am I going wrong? Help please? Sample

Using ssh for uptime?

2002-12-07 Thread Mark Weisman
I've got a script that I'm working on that will use SSH to check the uptime on servers within my domain. However, I'm unsure of how exactly to do this this is what I have so far. ##!/usr/bin/perl #My (@machines,$host,$user,$pass) #Open(INFILE,machines.txt) # or die Error opening

Re: Using ssh for uptime?

2002-12-07 Thread chad kellerman
Mark, It may be easier to go by route of the Net::SSH::Perl module or Net::SSH module #!/usr/bin/perl use strict; use warnings; my $user = bob; my @hosts = host1, host2, host3, host3; foreach my $host (@hosts) : my $cmd = /usr/bin/uptime; my $ssh = Net::SSH::Perl-new( $host, port

Re: Using ssh for uptime?

2002-12-07 Thread chad kellerman
Dammit, got the split wrong. try this: my ( $time, $uptime ) = ( split / /, $out[0] )[0,1]; my bad.. chad On Sat, 2002-12-07 at 12:11, Mark Weisman wrote: I've got a script that I'm working on that will use SSH to check the uptime on servers within my domain. However, I'm unsure of how

Re: Using ssh for uptime?

2002-12-07 Thread Mark Goland
) || die Error opening machines.txt.$!,stopped chomp ( @machines = INFILE ); Close(INFILE); Foreach my $rec (@machines) { ($host,$user,$pass) = split(/,/, $rec); open2(*RD_HD, *WR_FH, ssh $user\@$host uptime) || die cant fork a child; RD_FH; if( m/password/ ){ print

Re: Using ssh for uptime?

2002-12-07 Thread Dr. Poo
HAHAHAHaHa always happens! -Chris On Saturday 07 December 2002 11:23 am, chad kellerman wrote: Dammit, got the split wrong. try this: my ( $time, $uptime ) = ( split / /, $out[0] )[0,1]; my bad.. chad On Sat, 2002-12-07 at 12:11, Mark Weisman wrote: I've got a script

uptime

2002-11-13 Thread dan
how may it be possible to say how long it was before a certain time? say for instance i have the variable $starttime = time(); then, later an uptime was called. the time of the uptime being $timenow = time(); $runningtime = $runningtime - $timenow; now i have the amount of time the program has

RE: uptime

2002-11-13 Thread Timothy Johnson
, November 13, 2002 12:41 PM To: [EMAIL PROTECTED] Subject: uptime how may it be possible to say how long it was before a certain time? say for instance i have the variable $starttime = time(); then, later an uptime was called. the time of the uptime being $timenow = time(); $runningtime

Re: uptime

2002-10-04 Thread zentara
On 03 Oct 2002 09:25:03 -0400, [EMAIL PROTECTED] (Chad Kellerman) wrote: Hi everyone, What would be the easiest way to find the uptime of a linux machine? I don't want to use a system call. Is there a module I can use? Or do I have to open /proc/uptime and calculate it thru there? Here's

Re: uptime

2002-10-04 Thread david
Chad Kellerman wrote: Hi everyone, What would be the easiest way to find the uptime of a linux machine? I don't want to use a system call. Is there a module I can use? Or do I have to open /proc/uptime and calculate it thru there? Thanks for the help.. Chad yes. try

uptime

2002-10-03 Thread chad kellerman
Hi everyone, What would be the easiest way to find the uptime of a linux machine? I don't want to use a system call. Is there a module I can use? Or do I have to open /proc/uptime and calculate it thru there? Thanks for the help.. Chad -- Chad Kellerman Jr. Systems Administrator

Re: uptime

2002-10-03 Thread Rus Foster
On 3 Oct 2002, chad kellerman wrote: Hi everyone, What would be the easiest way to find the uptime of a linux machine? I don't want to use a system call. Is there a module I can use? Or do I have to open /proc/uptime and calculate it thru there? Prase the output of the command

Re: Uptime on Remote computer?

2002-08-14 Thread Mat Harris
you could try snmp but that (in my experience) always reports the wrong time if over 2 days. On Sun, Aug 11, 2002 at 01:19:13PM -0800, Mark Weisman wrote: Hello List: What is the command structure to grab an uptime request from a remote computer? I have several systems in my organization

RE: Uptime on Remote computer?

2002-08-14 Thread Meidling, Keith, CTR, OSD-C3I
Here is a script I use to check system up time. You can specify a remote server as an argument and it will remotely check the uptime for that server. This goes into the perfmon stats and gets the information from there. Keith --cut here

AW: Uptime on Remote computer?

2002-08-12 Thread Angerstein
. -Ursprüngliche Nachricht- Von: Mark Weisman [mailto:[EMAIL PROTECTED]] Gesendet am: Sonntag, 11. August 2002 23:19 An: [EMAIL PROTECTED] Betreff: Uptime on Remote computer? Hello List: What is the command structure to grab an uptime request from a remote computer? I have several systems in my

Re: Uptime on Remote computer?

2002-08-12 Thread Steve Maroney
There are many ways. Check out one method on my site @ www.stevenet.net. .. Like it ? Its pretty simple ... Let me know and Ill tell you how I did it. Thank you, Steve Maroney On Sun, 11 Aug 2002, Mark Weisman wrote: Hello List: What is the command structure to grab an uptime request

RE: Uptime on Remote computer?

2002-08-12 Thread Mark Weisman
USA http://www.outlander.us [EMAIL PROTECTED] -Original Message- From: Morten Liebach [mailto:[EMAIL PROTECTED]] Sent: Sunday, August 11, 2002 6:00 PM To: [EMAIL PROTECTED] Subject: Re: Uptime on Remote computer? On 2002-08-11 13:19:13 -0800, Mark Weisman wrote: Hello List: What

Re: Uptime on Remote computer?

2002-08-12 Thread 'Morten Liebach'
-l $machines{$host} $host uptime`; } script end -- Morten Liebach [EMAIL PROTECTED], http://m.mongers.org/ PGP-key: http://m.mongers.org/m_gpg.asc -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: Uptime on Remote computer?

2002-08-12 Thread drieux
On Sunday, August 11, 2002, at 02:19 , Mark Weisman wrote: Hello List: What is the command structure to grab an uptime request from a remote computer? I have several systems in my organization that I would like to grab the uptime for, then post them to a dynamic web page. The web page

Uptime on Remote computer?

2002-08-11 Thread Mark Weisman
Hello List: What is the command structure to grab an uptime request from a remote computer? I have several systems in my organization that I would like to grab the uptime for, then post them to a dynamic web page. The web page I've already got done, I just need the command structure

Re: Uptime on Remote computer?

2002-08-11 Thread Morten Liebach
On 2002-08-11 13:19:13 -0800, Mark Weisman wrote: Hello List: What is the command structure to grab an uptime request from a remote computer? I have several systems in my organization that I would like to grab the uptime for, then post them to a dynamic web page. The web page I've already

Re: extract uptime for linux box w/perl

2001-12-20 Thread Stef
Damn if you're gonna do it this way , why not just do: uptime Thus spake John W. Krahn on 20-Dec-2001 : - perl -le'print join,,(split/,/,`uptime`)[0..2]' ~~~ E-Mail: Stef [EMAIL PROTECTED] Date:20-Dec-2001 Time:11:05:43 XFMail

RE: extract uptime for linux box w/perl

2001-12-20 Thread Steven Hetland
I misunderstood. I thought Ken was asking the opposite of what Jim posted... If you want a least effort solution, you can do it without perl. Just modify your bash script: w | head -1 | cut -d, -f1-3 A cleaner way would be to just use uptime, as Ken said: uptime | cut -d, -f1

Re: extract uptime for linux box w/perl

2001-12-20 Thread Kevin Meltzer
Am I just the overly paranoid one? But IMO doing this can be dangerous. Tainting isn't just for CGIs, and adding a -T to this shows it can be dangerous ($ENV{PATH} issue, since you don't really know what uptime you will end up calling). Again, I may be the overly-paranoid (read safe) one

extract uptime for linux box w/perl

2001-12-19 Thread KeN ClarK
right now i do w | head -1 and get what's below my signature. I want to clean that up, cutting it after the # of users, so that everything after AND including the third comma is removed from that line. Then take that and add it to my signature script. i can either send it to a new file and

Re: extract uptime for linux box w/perl

2001-12-19 Thread Jim Conner
on what you are really trying to do here but the first thing that comes to mind is... if you want your uptime...why are you using w | blah blah blah? You could simply use uptime(1) couldn't you? If you are really hell-bent on going the 'w | head -1' direction and redirecting that into a file, you

RE: extract uptime for linux box w/perl

2001-12-19 Thread Jim Conner
uptime, as (correction) Jim said: uptime | cut -d, -f1-3 Since it's a perl list, and you asked how to do it with perl... Yes. Thank you for doing this. I apologize for the OT'ness of my reply. :) Let me continue a perl tradition: perl -MShell -e 'chomp($uptime = uptime());($a,$b,$c