[30158] in Perl-Users-Digest
Perl-Users Digest, Issue: 1401 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 28 11:09:42 2008
Date: Fri, 28 Mar 2008 08:09:07 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Fri, 28 Mar 2008 Volume: 11 Number: 1401
Today's topics:
5.10. <greymausg@mail.com>
Re: 5.10. <benkasminbullock@gmail.com>
Re: 5.10. <greymausg@mail.com>
empty variables - getting rid of "uninitialized value" <tch@nospam.syneticon.net>
Re: empty variables - getting rid of "uninitialized val <noreply@gunnar.cc>
Re: empty variables - getting rid of "uninitialized val <someone@example.com>
Installing module Apache2::Reload failed ronny204@googlemail.com
Re: Installing module Apache2::Reload failed <joost@zeekat.nl>
Re: Installing module Apache2::Reload failed ronny204@googlemail.com
Re: Installing module Apache2::Reload failed <joost@zeekat.nl>
Re: Installing module Apache2::Reload failed ronny204@googlemail.com
Re: Readline using foreach and while <ben@morrow.me.uk>
Re: Readline using foreach and while <simon.chao@gmail.com>
Re: Readline using foreach and while <szrRE@szromanMO.comVE>
sockets giving me gray hairs. server keeps dying <lekonna@gmail.com>
Re: sockets giving me gray hairs. server keeps dying <lekonna@gmail.com>
Re: ssh ssh <josef.moellers@fujitsu-siemens.com>
Win32::OLE different connections methods produce differ <henrikas.j@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 28 Mar 2008 09:36:36 GMT
From: greymaus <greymausg@mail.com>
Subject: 5.10.
Message-Id: <slrnfupeu6.3oe.greymausg@maus.org>
I have downloaded, compiled, and `make install' perl5.10.0, ok
3 Questions,`
1) even if I `./configure --prefix=/usr', it still installs
to `/usr/local'. How do I get it to instal to /usr/? (Just 'mv
/usr/local/bin/perl5.10 /usr/bin'?
2) Do I just relink /usr/bin/perl /usr/local/bin/perl5.10 to have it
run from the command line ('perl -e (whatever')
3) Is there any way of reloading the modules i have under perl5.8.8
quickly ?
--
Greymaus
Anything that can not kill you is a boring experience.
------------------------------
Date: Fri, 28 Mar 2008 11:53:24 +0000 (UTC)
From: Ben Bullock <benkasminbullock@gmail.com>
Subject: Re: 5.10.
Message-Id: <fsim7k$51h$1@ml.accsnet.ne.jp>
On Fri, 28 Mar 2008 09:36:36 +0000, greymaus wrote:
> I have downloaded, compiled, and `make install' perl5.10.0, ok 3
> Questions,`
> 1) even if I `./configure --prefix=/usr', it still installs to
> `/usr/local'. How do I get it to instal to /usr/? (Just 'mv
> /usr/local/bin/perl5.10 /usr/bin'?
ben /usr/local/src/perl-5.10.0 502 $ ls configure
ls: configure: No such file or directory
ben /usr/local/src/perl-5.10.0 503 $ ./Configure
/usr/local/src/perl-5.10.0/UU
Beginning of configuration questions for perl5.
...
By default, perl5 will be installed in /usr/local/bin, manual pages
under /usr/local/man, etc..., i.e. with /usr/local as prefix for all
installation directories. Typically this is something like /usr/local.
If you wish to have binaries under /usr/bin but other parts of the
installation under /usr/local, that's ok: you will be prompted
separately for each of the installation directories, the prefix being
only used to set the defaults.
Installation prefix to use? (~name ok) [/usr/local]
> 2) Do I just relink /usr/bin/perl /usr/local/bin/perl5.10 to have it run
> from the command line ('perl -e (whatever')
Pathname where the public executables will reside? (~name ok)
[/usr/local/bin]
> 3) Is there any way of reloading the modules i have under perl5.8.8
> quickly ?
...
In order to ease the process of upgrading, this version of perl
can be configured to use modules built and installed with earlier
versions of perl that were installed under /usr/local. Specify here
the list of earlier versions that this version of perl should check.
If Configure detected no earlier versions of perl installed under
/usr/local, then the list will be empty. Answer 'none' to tell perl
to not search earlier versions.
The default should almost always be sensible, so if you're not sure,
just accept the default.
List of earlier versions to include in @INC? [none]
------------------------------
Date: 28 Mar 2008 13:36:35 GMT
From: greymaus <greymausg@mail.com>
Subject: Re: 5.10.
Message-Id: <slrnfuptbs.3q9.greymausg@maus.org>
On 2008-03-28, Ben Bullock <benkasminbullock@gmail.com> wrote:
> On Fri, 28 Mar 2008 09:36:36 +0000, greymaus wrote:
>
>> I have downloaded, compiled, and `make install' perl5.10.0, ok 3
>> Questions,`
>> 1) even if I `./configure --prefix=/usr', it still installs to
>> `/usr/local'. How do I get it to instal to /usr/? (Just 'mv
>> /usr/local/bin/perl5.10 /usr/bin'?
>
> ben /usr/local/src/perl-5.10.0 502 $ ls configure
> ls: configure: No such file or directory
>
> ben /usr/local/src/perl-5.10.0 503 $ ./Configure
> /usr/local/src/perl-5.10.0/UU
>
> Beginning of configuration questions for perl5.
> ...
> By default, perl5 will be installed in /usr/local/bin, manual pages
> under /usr/local/man, etc..., i.e. with /usr/local as prefix for all
> installation directories. Typically this is something like /usr/local.
> If you wish to have binaries under /usr/bin but other parts of the
> installation under /usr/local, that's ok: you will be prompted
> separately for each of the installation directories, the prefix being
> only used to set the defaults.
>
> Installation prefix to use? (~name ok) [/usr/local]
>
>> 2) Do I just relink /usr/bin/perl /usr/local/bin/perl5.10 to have it run
>> from the command line ('perl -e (whatever')
>
> Pathname where the public executables will reside? (~name ok)
> [/usr/local/bin]
>
>> 3) Is there any way of reloading the modules i have under perl5.8.8
>> quickly ?
>
> ...
>
> In order to ease the process of upgrading, this version of perl
> can be configured to use modules built and installed with earlier
> versions of perl that were installed under /usr/local. Specify here
> the list of earlier versions that this version of perl should check.
> If Configure detected no earlier versions of perl installed under
> /usr/local, then the list will be empty. Answer 'none' to tell perl
> to not search earlier versions.
>
> The default should almost always be sensible, so if you're not sure,
> just accept the default.
> List of earlier versions to include in @INC? [none]
Thanks
--
Greymaus
Anything that can not kill you is a boring experience.
------------------------------
Date: Fri, 28 Mar 2008 10:34:13 +0100
From: Tomasz Chmielewski <tch@nospam.syneticon.net>
Subject: empty variables - getting rid of "uninitialized value" warnings?
Message-Id: <fsie2l$g0f$1@online.de>
I have perl code which should do some action only if:
- the variable does not begin with "#" (commented out),
- the variable is not empty
use strict;
use warnings;
my @array = ("# Comment", "/usr/bin/binary --test", "");
foreach my $var (@array) {
my @execargs = split(/#/, $var);
if ( $execargs[0] ne '' ) { print "$var 0: |$execargs[0]|\n" }
}
Unfortunately, it shows uninitialized value warnings for the empty
variable (""):
$ perl test.pl
/usr/bin/binary --test 0: |/usr/bin/binary --test|
Use of uninitialized value $execargs[0] in string ne at test.pl line 14.
Using:
if ( defined $execargs[0] ) { print "$var 0: |$execargs[0]|\n" }
is not a solution either, because $execargs[0] will be defined for a
case with "# Comment" and an undesired action will be made for this element:
$ perl test.pl
# Comment 0: ||
/usr/bin/binary --test 0: |/usr/bin/binary --test|
How can I get rid of warnings if I make tests with "if" and some
variables are empty?
Should I just ignore it? Or use "no warnings" just for that piece of
code throwing a warning?
--
Tomasz Chmielewski
http://wpkg.org
------------------------------
Date: Fri, 28 Mar 2008 11:16:25 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: empty variables - getting rid of "uninitialized value" warnings?
Message-Id: <653uvmF291rggU1@mid.individual.net>
Tomasz Chmielewski wrote:
> I have perl code which should do some action only if:
>
> - the variable does not begin with "#" (commented out),
> - the variable is not empty
>
> use strict;
> use warnings;
>
> my @array = ("# Comment", "/usr/bin/binary --test", "");
>
> foreach my $var (@array) {
>
> my @execargs = split(/#/, $var);
>
> if ( $execargs[0] ne '' ) { print "$var 0: |$execargs[0]|\n" }
>
> }
>
> Unfortunately, it shows uninitialized value warnings for the empty
> variable (""):
>
> $ perl test.pl
> /usr/bin/binary --test 0: |/usr/bin/binary --test|
> Use of uninitialized value $execargs[0] in string ne at test.pl line 14.
>
> Using:
>
> if ( defined $execargs[0] ) { print "$var 0: |$execargs[0]|\n" }
>
> is not a solution either, because $execargs[0] will be defined for a
> case with "# Comment" and an undesired action will be made for this
> element:
>
> $ perl test.pl
> # Comment 0: ||
> /usr/bin/binary --test 0: |/usr/bin/binary --test|
>
> How can I get rid of warnings if I make tests with "if" and some
> variables are empty?
>
> Should I just ignore it? Or use "no warnings" just for that piece of
> code throwing a warning?
foreach my $var (@array) {
next unless defined $var and length $var;
next if substr($var, 0, 1) eq '#';
print "$var\n";
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 28 Mar 2008 12:04:42 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: empty variables - getting rid of "uninitialized value" warnings?
Message-Id: <u95Hj.3261$9X3.863@edtnps82>
Tomasz Chmielewski wrote:
> I have perl code which should do some action only if:
>
> - the variable does not begin with "#" (commented out),
> - the variable is not empty
>
>
> use strict;
> use warnings;
>
> my @array = ("# Comment", "/usr/bin/binary --test", "");
>
> foreach my $var (@array) {
>
> my @execargs = split(/#/, $var);
>
> if ( $execargs[0] ne '' ) { print "$var 0: |$execargs[0]|\n" }
>
> }
>
>
> Unfortunately, it shows uninitialized value warnings for the empty
> variable (""):
>
> $ perl test.pl
> /usr/bin/binary --test 0: |/usr/bin/binary --test|
> Use of uninitialized value $execargs[0] in string ne at test.pl line 14.
$ perl -le'
use strict;
use warnings;
my @array = ( "# Comment", "/usr/bin/binary --test", "" );
foreach my $var ( @array ) {
next if $var =~ /^(?:#|$)/;
print $var;
}
'
/usr/bin/binary --test
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
------------------------------
Date: Fri, 28 Mar 2008 02:20:25 -0700 (PDT)
From: ronny204@googlemail.com
Subject: Installing module Apache2::Reload failed
Message-Id: <3b50f7f4-9352-45c4-a529-a2bd37692d7a@a70g2000hsh.googlegroups.com>
Dears,
I am trying to install the module Apache2::Reload but when I do perl
Makefile.PL it returns the quote: "You don't seem to have mod_perl 1.0
installed at Makefile.PL line 112."
Makefile.pl (line 112 ff):
-------------------- 8< --------------------
if ($mod_perl::VERSION >= 1.99) {
# so we don't pick 2.0 version if 1.0 is wanted
die "You don't seem to have mod_perl 1.0 installed";
}
-------------------- 8< --------------------
We have installed mod_perl 1.999021 and Apache2 on Solaris 9.
Any idea, how it can be done?
Best regards,
Ronny
------------------------------
Date: Fri, 28 Mar 2008 11:45:15 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Installing module Apache2::Reload failed
Message-Id: <87hcer9lfo.fsf@zeekat.nl>
ronny204@googlemail.com writes:
> Dears,
>
> I am trying to install the module Apache2::Reload but when I do perl
> Makefile.PL it returns the quote: "You don't seem to have mod_perl 1.0
> installed at Makefile.PL line 112."
The Apache::Reload distribution installs different modules depending if
you want mod_perl 1.x or mod_perl 2. It looks like you can force
mod_perl 2 by setting the MOD_PERL_2_BUILD environment variable before
running Makefile.PL
Joost.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: Fri, 28 Mar 2008 06:56:29 -0700 (PDT)
From: ronny204@googlemail.com
Subject: Re: Installing module Apache2::Reload failed
Message-Id: <79586168-9930-435b-95df-202e134888f4@s37g2000prg.googlegroups.com>
Dear Joost.
I've tried to set this variable and it now returns a quote: "You don't
seem to have mod_perl 2.0 installed at Makefile.PL line 120." :(
Any idea what now?
Ronny.
------------------------------
Date: Fri, 28 Mar 2008 15:18:31 +0100
From: Joost Diepenmaat <joost@zeekat.nl>
Subject: Re: Installing module Apache2::Reload failed
Message-Id: <87abkj7wzs.fsf@zeekat.nl>
ronny204@googlemail.com writes:
> Dear Joost.
>
> I've tried to set this variable and it now returns a quote: "You don't
> seem to have mod_perl 2.0 installed at Makefile.PL line 120." :(
>
> Any idea what now?
Sounds like you may not have a complete mod_perl 2 installation, or you
have two or more perls installed and you're trying to install
Apache::Reload using the wrong one. You may want to try to re-install
mod_perl, and check for additional perl installs.
If that still doesn't help or turn up more information, I'm out of ideas.
--
Joost Diepenmaat | blog: http://joost.zeekat.nl/ | work: http://zeekat.nl/
------------------------------
Date: Fri, 28 Mar 2008 08:05:39 -0700 (PDT)
From: ronny204@googlemail.com
Subject: Re: Installing module Apache2::Reload failed
Message-Id: <1d197adf-4364-4f08-8368-b22504d8e18d@i12g2000prf.googlegroups.com>
Thank you very much for your response. Here are the significant lines
out of Makefile.PL:
-------------------- 8< --------------------
if ($wanted == 1) {
require_mod_perl();
if ($mod_perl::VERSION >= 1.99) {
# so we don't pick 2.0 version if 1.0 is wanted
die "You don't seem to have mod_perl 1.0 installed";
}
$selected = 1;
}
elsif ($wanted == 2) {
#warn "Looking for mod_perl 2.0";
require_mod_perl();
if ($mod_perl::VERSION < 2.0) {
die "You don't seem to have mod_perl 2.0 installed";
}
$selected = 2;
}
-------------------- 8< --------------------
Our mod_perl -Version is 1.999021. This is greater than 1.99 and
smaller than 2.0 ... so both options can not work. This is very strange.
------------------------------
Date: Fri, 28 Mar 2008 03:57:05 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Readline using foreach and while
Message-Id: <ht6ub5-5no.ln1@osiris.mauzo.dyndns.org>
Quoth "szr" <szrRE@szromanMO.comVE>:
>
> Actually the behaviors of "for (@ary)" and "for (@ary, ())" do seem
> consistant if you really think about it. The resulting list is what it
> iterates over (from the first element, to what ever *count* is... in the
> former case *count* come fro mthe array, and since the condition is
> checked at the start of each iteration, if the array is added to, the
> count is incremented.
>
> In the latter case, a new list is created from contents of @ary + an
> empty list, which gives you a new list, which contains the values of
> @ary, but is a new seperate list, and thus is not effected by changes to
> @ary because it has it's own copy of @ary's values.
OK, now explain to me why
my @ary = qw/a b c/;
print map { /c/ and push @ary, 'd'; $_ } @ary;
*doesn't* work like that :).
Ben
------------------------------
Date: Fri, 28 Mar 2008 07:13:29 -0700 (PDT)
From: nolo contendere <simon.chao@gmail.com>
Subject: Re: Readline using foreach and while
Message-Id: <a7b461c9-6b77-488d-8d4e-76402afc89ea@y21g2000hsf.googlegroups.com>
On Mar 27, 11:26=A0pm, "szr" <sz...@szromanMO.comVE> wrote:
> Peter J. Holzer wrote:
> > On 2008-03-27 04:45, szr <sz...@szromanMO.comVE> wrote:
> >> nolo contendere wrote:
> >>> Provably untrue. See Ben's example. I'll restate the concept below.
>
> >>> my @ary =3D qw/a b c/;
> >>> # for (@ary, ()) {
> >>> # for ( (), @ary ) {
> >>> for ( @ary ) {
> >>> =A0 =A0 push @ary, 'd' if /c/;
> >>> =A0 =A0 print;
> >>> }
>
> >>> ...
>
> >>> only the uncommented 'for' line prints a 'd' at the end. so what you
> >>> say MAY be true if LIST is ONLY an array.
>
> >> Isn't that because the two commented one are two lists being combined
> >> into a new list, and it's *that* new list that's being iterated
> >> over, so even if you add to @ary, it doesn't change the "new list",
> >> which is just that, a new list created at the start of the loop
> >> before iterating begins - therefore the values of the new list are
> >> set and @ary has nothing to do with it after the create of the "new
> >> list."
>
> > Yes. But the same should be true for
>
> > for (@ary) {
> > =A0 =A0...
> > }
>
> > for() expects a list, the list is constructed from the elements of
> > @ary. If you modify @ary after the list is constructed, the list
> > shouldn't be affected, but it is. I think Ben Morrow is right here:
> > This smells like an optimization: If there is only a single array, it
> > can be used directly instead of creating a list from it.
>
> Actually the behaviors of "for (@ary)" and "for (@ary, ())" do seem
> consistant if you really think about it. The resulting list is what it
> iterates over (from the first element, to what ever *count* is... in the
> former case *count* come fro mthe array, and since the condition is
> checked at the start of each iteration, if the array is added to, the
> count is incremented.
>
> In the latter case, a new list is created from contents of @ary + an
> empty list, which gives you a new list, which contains the values of
> @ary, but is a new seperate list, and thus is not effected by changes to
> @ary because it has it's own copy of @ary's values.
>
Is this explanation based on analysis of the source implementation? or
are you just using inductive reasoning to extrapolate a general rule
from a few test cases?
------------------------------
Date: Fri, 28 Mar 2008 08:00:47 -0700
From: "szr" <szrRE@szromanMO.comVE>
Subject: Re: Readline using foreach and while
Message-Id: <fsj16v01ove@news2.newsguy.com>
Ben Morrow wrote:
> Quoth "szr" <szrRE@szromanMO.comVE>:
>>
>> Actually the behaviors of "for (@ary)" and "for (@ary, ())" do seem
>> consistant if you really think about it. The resulting list is what
>> it iterates over (from the first element, to what ever *count* is...
>> in the former case *count* come fro mthe array, and since the
>> condition is checked at the start of each iteration, if the array is
>> added to, the count is incremented.
>>
>> In the latter case, a new list is created from contents of @ary + an
>> empty list, which gives you a new list, which contains the values of
>> @ary, but is a new seperate list, and thus is not effected by
>> changes to @ary because it has it's own copy of @ary's values.
>
> OK, now explain to me why
>
> my @ary = qw/a b c/;
> print map { /c/ and push @ary, 'd'; $_ } @ary;
>
> *doesn't* work like that :).
>
> Ben
For starters, we were talking about for(LIST), not map.
perldoc -f map
map BLOCK LIST
map EXPR,LIST
Evaluates the BLOCK or EXPR for each element of LIST
[...]
It would seem map does not re-check the count of the list each time
around like for those, which sort of makes sense, as it's supposed to
eval the block/expression for "each element", which to me means each
elemt of the list originally passed to map.
"map" and "for"/"foreach" are two similar but different beasts :)
--
szr
------------------------------
Date: Fri, 28 Mar 2008 00:55:07 -0700 (PDT)
From: lekonna <lekonna@gmail.com>
Subject: sockets giving me gray hairs. server keeps dying
Message-Id: <584aaebe-3585-409f-b29c-6be83ba52669@s12g2000prg.googlegroups.com>
Hi guys,
i'm having bit of a hard time getting my very simple multiplexing
socket server staying alive. It keeps exiting without giving any
messages, and since i'm running the bugger in while(1) loop i don't
quite get why the heck it does that.
Its a very basic echo server with some added features for keeping
track of users. Basicly i wanted to learn how to use sockets in flash
and needed something to echo the poo that i send back to me so i came
up with this quick and dirty solution. Now unfortunately it seems that
the trusty old work-horse perl keeps dying on me.
Heres the link to attachr with syntax highlighted version of the
server implementation.
http://attachr.com/10605
very basic server with some ugly xml hacks in it.
Is there a way to enable some sort of debug info on what actually goes
wrong?
Br,
Lekonna
------------------------------
Date: Fri, 28 Mar 2008 02:36:05 -0700 (PDT)
From: lekonna <lekonna@gmail.com>
Subject: Re: sockets giving me gray hairs. server keeps dying
Message-Id: <0ab6e380-c56c-4375-88a8-46c2cf5387f9@d4g2000prg.googlegroups.com>
On Mar 28, 9:55 am, lekonna <leko...@gmail.com> wrote:
> Hi guys,
> i'm having bit of a hard time getting my very simple multiplexing
> socket server staying alive. It keeps exiting without giving any
> messages, and since i'm running the bugger in while(1) loop i don't
> quite get why the heck it does that.
>
> Its a very basic echo server with some added features for keeping
> track of users. Basicly i wanted to learn how to use sockets in flash
> and needed something to echo the poo that i send back to me so i came
> up with this quick and dirty solution. Now unfortunately it seems that
> the trusty old work-horse perl keeps dying on me.
>
> Heres the link to attachr with syntax highlighted version of the
> server implementation.http://attachr.com/10605
>
> very basic server with some ugly xml hacks in it.
>
> Is there a way to enable some sort of debug info on what actually goes
> wrong?
>
> Br,
> Lekonna
some added specs, i ran it on 64 bit rhel 5.1
with perl servscript.pl 61003 > log.txt
------------------------------
Date: Fri, 28 Mar 2008 09:26:57 +0100
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: ssh ssh
Message-Id: <fsia21$v8e$1@nntp.fujitsu-siemens.com>
jammer wrote:
> I am trying to write a script that takes a list of hosts and sshs into
> the first one and then can ssh to other ones. I can only ssh to the
> other hosts from the first host.
IIUC you want to ssh to one host, then, from that host, ssh to another
host, from there on ssh to yet another host ...
You might want to look at Expect. I've used it to repeatedly log into a
remote host via a pretty complex series of internal and external hosts
which, in part, perform callbacks for security reasons.
--
These are my personal views and not those of Fujitsu Siemens Computers!
Josef Möllers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://www.fujitsu-siemens.com/imprint.html
------------------------------
Date: Fri, 28 Mar 2008 07:46:04 -0700 (PDT)
From: HmJ <henrikas.j@gmail.com>
Subject: Win32::OLE different connections methods produce different results
Message-Id: <c6e23c07-aa0f-468f-9c99-02e954b55441@s37g2000prg.googlegroups.com>
Hi,
It seems what when using perl Win32::OLE for WMI queries it produces
different results depending on method used to connect to server,
examples bellow, can somebody explain this issue?
Examples
Using ConnectServer() I get
ActiveSessions: 0
TotalSessions: 0
Script
#!/usr/bin/perl
use strict;
use Win32::OLE('in');
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;
my $computer = "server";
my $user = 'DOMAIN\USER';
my $pwd = "password";
my $wmipath = 'root\\cimv2';
print "\n";
print "==========================================\n";
print "Computer: $computer\n";
print "==========================================\n";
my $wmiwebloc = Win32::OLE->new('WbemScripting.SWbemLocator');
my $wmi = $wmiwebloc->ConnectServer($computer,$wmipath,$user,$pwd);
$wmi->{Security_}->{ImpersonationLevel} = 3;
if (Win32::OLE::LastError()) {
print 'Authentication failed: ' . ('' . Win32::OLE::LastError()),
"\n";
}
my $colItems = $wmi->ExecQuery("SELECT * FROM
Win32_PerfRawData_TermService_TerminalServices", "WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);
foreach my $objItem (in $colItems) {
print "ActiveSessions: $objItem->{ActiveSessions}\n";
print "Caption: $objItem->{Caption}\n";
print "Description: $objItem->{Description}\n";
print "Frequency_Object: $objItem->{Frequency_Object}\n";
print "Frequency_PerfTime: $objItem->{Frequency_PerfTime}\n";
print "Frequency_Sys100NS: $objItem->{Frequency_Sys100NS}\n";
print "InactiveSessions: $objItem->{InactiveSessions}\n";
print "Name: $objItem->{Name}\n";
print "Timestamp_Object: $objItem->{Timestamp_Object}\n";
print "Timestamp_PerfTime: $objItem->{Timestamp_PerfTime}\n";
print "Timestamp_Sys100NS: $objItem->{Timestamp_Sys100NS}\n";
print "TotalSessions: $objItem->{TotalSessions}\n";
print "\n";
}
Output
==========================================
Computer: server
==========================================
ActiveSessions: 0
Caption:
Description:
Frequency_Object: 10000000
Frequency_PerfTime: 2605950000
Frequency_Sys100NS: 10000000
InactiveSessions: 0
Name:
Timestamp_Object: 128511849607031250
Timestamp_PerfTime: 5097696116216139
Timestamp_Sys100NS: 18446742399360059616
TotalSessions: 0
While Using Win32::OLE->GetObject I get
ActiveSessions: 1
TotalSessions: 2
Script
#!/usr/bin/perl
use strict;
use Win32::OLE('in');
use constant wbemFlagReturnImmediately => 0x10;
use constant wbemFlagForwardOnly => 0x20;
my $computer = "server";
my $user = 'Domain\User';
my $pwd = "password";
my $wmipath = 'root\\cimv2';
print "\n";
print "==========================================\n";
print "Computer: $computer\n";
print "==========================================\n";
my $wmi = Win32::OLE->GetObject("winmgmts:\\\\$computer\\root\
\CIMV2") or die "WMI connection failed.\n";
my $colItems = $wmi->ExecQuery("SELECT * FROM
Win32_PerfRawData_TermService_TerminalServices", "WQL",
wbemFlagReturnImmediately | wbemFlagForwardOnly);
foreach my $objItem (in $colItems) {
print "ActiveSessions: $objItem->{ActiveSessions}\n";
print "Caption: $objItem->{Caption}\n";
print "Description: $objItem->{Description}\n";
print "Frequency_Object: $objItem->{Frequency_Object}\n";
print "Frequency_PerfTime: $objItem->{Frequency_PerfTime}\n";
print "Frequency_Sys100NS: $objItem->{Frequency_Sys100NS}\n";
print "InactiveSessions: $objItem->{InactiveSessions}\n";
print "Name: $objItem->{Name}\n";
print "Timestamp_Object: $objItem->{Timestamp_Object}\n";
print "Timestamp_PerfTime: $objItem->{Timestamp_PerfTime}\n";
print "Timestamp_Sys100NS: $objItem->{Timestamp_Sys100NS}\n";
print "TotalSessions: $objItem->{TotalSessions}\n";
print "\n";
}
Output
==========================================
Computer: server
==========================================
ActiveSessions: 1
Caption:
Description:
Frequency_Object: 10000000
Frequency_PerfTime: 2605950000
Frequency_Sys100NS: 10000000
InactiveSessions: 1
Name:
Timestamp_Object: 128511890915625000
Timestamp_PerfTime: 5108460132511734
Timestamp_Sys100NS: 18446742440665596616
TotalSessions: 2
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 1401
***************************************