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
于 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
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
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
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
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
于 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
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
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/
::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
"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
[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
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
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
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
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
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
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
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
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
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
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
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(
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
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
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
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
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
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
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
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.
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]
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
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
.
> -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
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
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
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
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
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
>~~
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
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
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
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:
&
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
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
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
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
48 matches
Mail list logo