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 wa

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 addit

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 regula

Re: Linux Uptime

2010-12-16 Thread Katie T
On Fri, Dec 17, 2010 at 3:21 AM, Katie T wrote: > On Fri, Dec 17, 2010 at 2:25 AM, Jeff Peng 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 wou

Re: Linux Uptime

2010-12-16 Thread Katie T
On Fri, Dec 17, 2010 at 2:25 AM, Jeff Peng 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 4

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 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

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 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

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: Using ssh for uptime?

2002-12-11 Thread zentara
::SSH. > >use strict; >use warnings; >use 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 = ; >ch

RE: Using ssh for uptime?

2002-12-10 Thread chad kellerman
"10.10.10.10"; my $cmd = "uptime"; sshopen3( "$user\@$host", *WRITER, *READER, *ERROR, "$cmd" ); my $uptime = ; chomp $uptime; print "$uptime\n"; something like that ought to so it... chad On Tue, 2002-12-10 at 11:44, Mark-Nathaniel Weisma

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 work

Re: Using ssh for uptime?

2002-12-09 Thread zentara
uot;zzztester"; my @hosts = qw(localhost 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

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

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

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

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

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

Re: Using ssh for uptime?

2002-12-07 Thread Mark Goland
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; ; if( m/password/ ){ print WR_FH "$pass\n"; print "\t\t\tHOST $host re

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

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 $ss

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,"; #Close(INFILE); #Foreac

RE: uptime

2002-11-13 Thread Timothy Johnson
mon.co.uk] Sent: Wednesday, 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(

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-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

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 cal

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 th

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 Administ

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

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 org

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.

Re: Uptime on Remote computer?

2002-08-12 Thread 'Morten Liebach'
amba => 'operator', > web => 'bofh', > ); > > foreach my $host (sort keys %machines) { > print $host . ':' . `ssh -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 Mark Weisman
n Group Anchorage,AK 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: &g

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

AW: Uptime on Remote computer?

2002-08-11 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 > compu

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

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 structur

Re: extract uptime for linux box w/perl

2001-12-20 Thread Daniel Gardner
Thursday, December 20, 2001, 4:02:00 AM, KeN ClarK wrote: > 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

Re: extract uptime for linux box w/perl

2001-12-20 Thread Jim Conner
At 08:28 12.20.2001 -0500, Kevin Meltzer wrote: >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

Re: extract uptime for linux box w/perl

2001-12-20 Thread Jim Conner
At 11:06 12.20.2001 +0200, Stef wrote: >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]' I love Perl :") - Jim >~~

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

RE: extract uptime for linux box w/perl

2001-12-20 Thread Steven Hetland
hat and add it to my > signature > script. Maybe 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 us

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]> Dat

Re: extract uptime for linux box w/perl

2001-12-20 Thread John W. Krahn
Jim Conner wrote: > > At 02:01 12.20.2001 -0500, Jim Conner wrote: > > > >At 00:26 12.20.2001 -0500, Steven Hetland wrote: > > > > > >There's probably a bazillion ways to accomplish this, but here's two ways: > > > > > >Example 1: &

RE: extract uptime for linux box w/perl

2001-12-19 Thread Jim Conner
n. The second solution you posted would be what I would have >suggested to be the best. > > >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 wou

RE: extract uptime for linux box w/perl

2001-12-19 Thread Jim Conner
out perl. Just >modify your bash script: > > w | head -1 | cut -d, -f1-3 > >A cleaner way would be to just use 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. Th

Re: extract uptime for linux box w/perl

2001-12-19 Thread Jim Conner
or less pointers so i can kludge through this one myself. Ok. So, I am quite confused 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 a

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 c