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/
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
于 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
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
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
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
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
于 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
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
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
[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
= 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
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
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
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
(/,/, $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
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
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
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
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
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
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
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
) || 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
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
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
, 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
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
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
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
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
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
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
.
-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
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
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
-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]
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
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
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
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
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
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
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
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
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
46 matches
Mail list logo