Re: WIN32::OLE WMI Out params

2009-12-05 Thread Michael
On Fri, 04 Dec 2009 17:10:26 -0800, Michael Ellery
mi...@s2technologies.com wrote:
 Michael wrote:
 Okay - Just to sum up the whole thing.
 
 The original VBScript EOF;
 
 Option Explicit
 
 Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups,
arrNodes,
 objItem
 
 Set objWMIService =
 GetObject(winmgmts:root\HewlettPackard\OpenView\data)
 
 Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup)
 Set objGetRoot = objOV_NodeGroup.GetRoot()
 objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True)
 
 WScript.Echo Child Group Count:   objChildGroups  vbCrLF
 
 For Each objItem In arrNodes
   WScript.Echo Name:   objItem.Name
 Next
 EOF
 
 Returns the following:
 
 Child Group Count: 25
 
 Name: {36716FD8-E600-46FB-90CA-1263E0C62509}
 Name: {38FF8E8E-2DDC-4895-A7EB-0DC7DF50EC25}
 Name: {3E575181-0225-4553-9722-46F841B9FA76}
 Name: {8A412133-F571-42BC-8A66-4B242EB3BAC4}
 Name: {E14D965C-1FBB-40EC-A784-5F9F39F82281}
 Name: OpenView_AIX
 Name: OpenView_External
 Name: OpenView_HPUX
 Name: OpenView_Linux
 Name: OpenView_NNM
 Name: OpenView_OpenVMS
 Name: OpenView_OpenVMS(itanium)
 Name: OpenView_SNMP
 Name: OpenView_Solaris
 Name: OpenView_Tru64
 Name: OpenView_Unknown
 Name: OpenView_Windows2000
 Name: OpenView_WindowsNT
 Name: OpenView_WindowsServer2003
 Name: OpenView_WindowsServer2008
 Name: OpenView_WindowsVista
 Name: OpenView_WindowsXP
 Name: Root_Special
 Name: Root_Unix
 Name: Root_Windows
 
 And the Perl-Script with the modification EOF;
 #!perl
 use strict;
 use warnings;
 use Win32::OLE qw(in with);
 use Win32::OLE::Variant;
 use Data::Dumper;
 
 my $objWMIService =
 Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or
 die
 WMI connection failed.\n;
 if (Win32::OLE- LastError() != 0) {
  print Error calling GetObject:  . Win32::OLE-LastError() . \n;
 exit 0;
 }
 
 my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup);
 if (Win32::OLE- LastError() != 0) {
  print Error calling Get:  . Win32::OLE-LastError() . \n;
 exit 0;
 }
 
 my $objGetRoot = $objOV_NodeGroup-GetRoot();
 if (Win32::OLE- LastError() != 0) {
  print Error calling GetRoot:  . Win32::OLE-LastError() . \n;
 exit 0;
 }
 
 my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0);
 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0);
 #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0);
 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);
 
 my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, True);
 if (Win32::OLE- LastError() != 0) {
  print Error calling GetChildNodeGroups:  . Win32::OLE-LastError() .
 \n;
 exit 0;
 }
 print Child Group Count:  . $objChildGroups . \n;
 
 print Dumper($nodes);
 
 
 foreach my $objItem (in $nodes) {
 print 'Name: ' . $objItem-{Name} . \n;
 }
 
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27197068)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27197828)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27198308)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); Returns
 ##Error calling GetChildNodeGroups: Win32::OLE(0.1709) error 0x80010105:
 The server threw an exception
 ##in METHOD/PROPERTYGET GetChildNodeGroups
 
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);
 Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27199076)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0);
 Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27197684)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27199620)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);
 Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27199524)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 Does any of this, make any sense to you guys?
 
 /Michael
 
 
 
 so, it looks like your Dumper statement is indicating a valid object in
 

Re: WIN32::OLE WMI Out params

2009-12-05 Thread Michael
On Sat, 05 Dec 2009 05:58:48 -0800, Michael Ellery
mi...@s2technologies.com wrote:
 Michael wrote:
 On Fri, 04 Dec 2009 17:10:26 -0800, Michael Ellery
 mi...@s2technologies.com wrote:
 Michael wrote:
 Okay - Just to sum up the whole thing.

 The original VBScript EOF;

 Option Explicit

 Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups,
 arrNodes,
 objItem

 Set objWMIService =
 GetObject(winmgmts:root\HewlettPackard\OpenView\data)

 Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup)
 Set objGetRoot = objOV_NodeGroup.GetRoot()
 objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True)

 WScript.Echo Child Group Count:   objChildGroups  vbCrLF

 For Each objItem In arrNodes
   WScript.Echo Name:   objItem.Name
 Next
 EOF

 Returns the following:

 Child Group Count: 25

 Name: {36716FD8-E600-46FB-90CA-1263E0C62509}
 Name: {38FF8E8E-2DDC-4895-A7EB-0DC7DF50EC25}
 Name: {3E575181-0225-4553-9722-46F841B9FA76}
 Name: {8A412133-F571-42BC-8A66-4B242EB3BAC4}
 Name: {E14D965C-1FBB-40EC-A784-5F9F39F82281}
 Name: OpenView_AIX
 Name: OpenView_External
 Name: OpenView_HPUX
 Name: OpenView_Linux
 Name: OpenView_NNM
 Name: OpenView_OpenVMS
 Name: OpenView_OpenVMS(itanium)
 Name: OpenView_SNMP
 Name: OpenView_Solaris
 Name: OpenView_Tru64
 Name: OpenView_Unknown
 Name: OpenView_Windows2000
 Name: OpenView_WindowsNT
 Name: OpenView_WindowsServer2003
 Name: OpenView_WindowsServer2008
 Name: OpenView_WindowsVista
 Name: OpenView_WindowsXP
 Name: Root_Special
 Name: Root_Unix
 Name: Root_Windows

 And the Perl-Script with the modification EOF;
 #!perl
 use strict;
 use warnings;
 use Win32::OLE qw(in with);
 use Win32::OLE::Variant;
 use Data::Dumper;

 my $objWMIService =
 Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or
 die
 WMI connection failed.\n;
 if (Win32::OLE- LastError() != 0) {
print Error calling GetObject:  . Win32::OLE-LastError() . \n;
 exit 0;
 }

 my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup);
 if (Win32::OLE- LastError() != 0) {
print Error calling Get:  . Win32::OLE-LastError() . \n;
 exit 0;
 }

 my $objGetRoot = $objOV_NodeGroup-GetRoot();
 if (Win32::OLE- LastError() != 0) {
print Error calling GetRoot:  . Win32::OLE-LastError() . \n;
 exit 0;
 }

 my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0);
 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0);
 #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF,
0);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0);
 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF,
0);

 my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, True);
 if (Win32::OLE- LastError() != 0) {
print Error calling GetChildNodeGroups:  . Win32::OLE-LastError()
.
 \n;
 exit 0;
 }
 print Child Group Count:  . $objChildGroups . \n;

 print Dumper($nodes);


 foreach my $objItem (in $nodes) {
 print 'Name: ' . $objItem-{Name} . \n;
 }

 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27197068)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.

 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27197828)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.

 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27198308)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.

 #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); Returns
 ##Error calling GetChildNodeGroups: Win32::OLE(0.1709) error
 0x80010105:
 The server threw an exception
 ##in METHOD/PROPERTYGET GetChildNodeGroups

 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF,
0);
 Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27199076)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.

 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0);
 Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27197684)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.

 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27199620)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.

 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF,
0);
 Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27199524)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.

 Does any of this, make any sense to you guys?

 /Michael


 so, it looks 

RE: WIN32::OLE WMI Out params

2009-12-04 Thread Steven Manross
Below...

 -Original Message-
 From: perl-win32-users-boun...@listserv.activestate.com 
 [mailto:perl-win32-users-boun...@listserv.activestate.com] On 
 Behalf Of Michael
 Sent: Thursday, December 03, 2009 6:45 AM
 To: perl-win32-users@listserv.ActiveState.com
 Subject: RE: WIN32::OLE WMI Out params
 
  When troubleshooting OLE issues, it is best to have the 
 following code 
  after each OLE command...
  
  If (Win32::OLE- LastError() != 0) {
print error calling blah:  . Win32::OLE- LastError() . \n;
exit 0;
  }
  
  ...Or something similar, so you can see what OLE had issues 
 with (if 
  anything).  It might lead you in a direction that fixes it.
  
  Steven
 
 Added to the script, but no issues reported.
 
 /Michael

Well, then my next guess is the use of the Variant module (because no
error is thrown from OLE).

Some OLE calls require to be cast of a certain type before they work.

use Win32::OLE::Variant;

my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0); 

#I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of
VT_ARRAY|VT_VARIANT

#then
my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE); 

Play around with this...  I'm not the greatest Variant script writer
here, to know exactly which combination will work (if this is it) based
on the object type as I've only run into this a few times before, but
you can get examples from your perl install here (depending on your perl
build version) of similar options to try and all the VT_* types:

C:\Perl\html\lib\Win32\OLE\Variant.html

HTH

P.S. I googled OV_NodeGroup and found someone else with your same
problem on an HP board (or so it seems).  :(

Steven

 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: WIN32::OLE WMI Out params

2009-12-04 Thread Michael
Hi Steven,

Well I tried your suggestion and I think that the Win32::OLE::Variant
module might be the solution, as I have found some other examples where WMI
[out] and variants are used.

http://www.infoqu.com/dev/perl-programming/using-perl-with-wmi-to-set-folder-level-permissions-16930-1/
http://www.perlmonks.org/?node_id=325823

However I'm in way over my head here, so unless someone could cut it out in
pieces , I don't think that 
I'll get any further.

/Michael


On Fri, 4 Dec 2009 02:12:03 -0700, Steven Manross ste...@manross.net
wrote:
 Below...
 
 -Original Message-
 From: perl-win32-users-boun...@listserv.activestate.com 
 [mailto:perl-win32-users-boun...@listserv.activestate.com] On 
 Behalf Of Michael
 Sent: Thursday, December 03, 2009 6:45 AM
 To: perl-win32-users@listserv.ActiveState.com
 Subject: RE: WIN32::OLE WMI Out params
 
  When troubleshooting OLE issues, it is best to have the 
 following code 
  after each OLE command...
  
  If (Win32::OLE- LastError() != 0) {
print error calling blah:  . Win32::OLE- LastError() . \n;
exit 0;
  }
  
  ...Or something similar, so you can see what OLE had issues 
 with (if 
  anything).  It might lead you in a direction that fixes it.
  
  Steven
 
 Added to the script, but no issues reported.
 
 /Michael
 
 Well, then my next guess is the use of the Variant module (because no
 error is thrown from OLE).
 
 Some OLE calls require to be cast of a certain type before they work.
 
 use Win32::OLE::Variant;
 
 my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0); 
 
 #I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of
 VT_ARRAY|VT_VARIANT
 
 #then
 my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE); 
 
 Play around with this...  I'm not the greatest Variant script writer
 here, to know exactly which combination will work (if this is it) based
 on the object type as I've only run into this a few times before, but
 you can get examples from your perl install here (depending on your perl
 build version) of similar options to try and all the VT_* types:
 
 C:\Perl\html\lib\Win32\OLE\Variant.html
 
 HTH
 
 P.S. I googled OV_NodeGroup and found someone else with your same
 problem on an HP board (or so it seems).  :(
 
 Steven
 
 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: WIN32::OLE WMI Out params

2009-12-04 Thread Michael Ellery
I haven't followed your thread closely, but it seems like the relevant
bits from your first link are these:

my $objSecDescriptor = Win32::OLE::Variant- new (VT_DISPATCH|VT_BYREF);
my $retval =
$objDirectorySecSetting-GetSecurityDescriptor($objSecDescriptor);

..which seems to be filling the $objSecDescriptor with an out param.

If your out param is an array, you might need to add VT_ARRAY to the
variant flags when you create it. Does something like that work for you ?

-Mike

Michael wrote:
 Hi Steven,
 
 Well I tried your suggestion and I think that the Win32::OLE::Variant
 module might be the solution, as I have found some other examples where WMI
 [out] and variants are used.
 
 http://www.infoqu.com/dev/perl-programming/using-perl-with-wmi-to-set-folder-level-permissions-16930-1/
 http://www.perlmonks.org/?node_id=325823
 
 However I'm in way over my head here, so unless someone could cut it out in
 pieces , I don't think that 
 I'll get any further.
 
 /Michael
 
 
 On Fri, 4 Dec 2009 02:12:03 -0700, Steven Manross ste...@manross.net
 wrote:
 Below...

 -Original Message-
 From: perl-win32-users-boun...@listserv.activestate.com 
 [mailto:perl-win32-users-boun...@listserv.activestate.com] On 
 Behalf Of Michael
 Sent: Thursday, December 03, 2009 6:45 AM
 To: perl-win32-users@listserv.ActiveState.com
 Subject: RE: WIN32::OLE WMI Out params

 When troubleshooting OLE issues, it is best to have the 
 following code 
 after each OLE command...

 If (Win32::OLE- LastError() != 0) {
   print error calling blah:  . Win32::OLE- LastError() . \n;
   exit 0;
 }

 ...Or something similar, so you can see what OLE had issues 
 with (if 
 anything).  It might lead you in a direction that fixes it.

 Steven
 Added to the script, but no issues reported.

 /Michael
 Well, then my next guess is the use of the Variant module (because no
 error is thrown from OLE).

 Some OLE calls require to be cast of a certain type before they work.

 use Win32::OLE::Variant;

 my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0); 

 #I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of
 VT_ARRAY|VT_VARIANT

 #then
 my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE); 

 Play around with this...  I'm not the greatest Variant script writer
 here, to know exactly which combination will work (if this is it) based
 on the object type as I've only run into this a few times before, but
 you can get examples from your perl install here (depending on your perl
 build version) of similar options to try and all the VT_* types:

 C:\Perl\html\lib\Win32\OLE\Variant.html

 HTH

 P.S. I googled OV_NodeGroup and found someone else with your same
 problem on an HP board (or so it seems).  :(

 Steven

 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: WIN32::OLE WMI Out params

2009-12-04 Thread Steven Manross
 

 -Original Message-
 From: perl-win32-users-boun...@listserv.activestate.com 
 [mailto:perl-win32-users-boun...@listserv.activestate.com] On 
 Behalf Of Michael Ellery
 Sent: Friday, December 04, 2009 11:59 AM
 To: Michael
 Cc: perl-win32-users@listserv.ActiveState.com
 Subject: Re: WIN32::OLE WMI Out params
 
 I haven't followed your thread closely, but it seems like the 
 relevant bits from your first link are these:
 
 my $objSecDescriptor = Win32::OLE::Variant- new 
 (VT_DISPATCH|VT_BYREF); my $retval = 
 $objDirectorySecSetting-GetSecurityDescriptor($objSecDescriptor);
 
 ..which seems to be filling the $objSecDescriptor with an out param.
 
 If your out param is an array, you might need to add VT_ARRAY 
 to the variant flags when you create it. Does something like 
 that work for you ?
 
 -Mike
 
 Michael wrote:
  Hi Steven,
  
  Well I tried your suggestion and I think that the 
 Win32::OLE::Variant 
  module might be the solution, as I have found some other examples 
  where WMI [out] and variants are used.
  
  
 http://www.infoqu.com/dev/perl-programming/using-perl-with-wmi-to-set-
  folder-level-permissions-16930-1/
  http://www.perlmonks.org/?node_id=325823
  
  However I'm in way over my head here, so unless someone 
 could cut it 
  out in pieces , I don't think that I'll get any further.
  
  /Michael
  
  
  On Fri, 4 Dec 2009 02:12:03 -0700, Steven Manross 
  ste...@manross.net
  wrote:
  Below...
 
  -Original Message-
  From: perl-win32-users-boun...@listserv.activestate.com
  
 [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf 
  Of Michael
  Sent: Thursday, December 03, 2009 6:45 AM
  To: perl-win32-users@listserv.ActiveState.com
  Subject: RE: WIN32::OLE WMI Out params
 
  When troubleshooting OLE issues, it is best to have the
  following code
  after each OLE command...
 
  If (Win32::OLE- LastError() != 0) {
print error calling blah:  . Win32::OLE- LastError() . \n;
exit 0;
  }
 
  ...Or something similar, so you can see what OLE had issues
  with (if
  anything).  It might lead you in a direction that fixes it.
 
  Steven
  Added to the script, but no issues reported.
 
  /Michael
  Well, then my next guess is the use of the Variant module 
 (because no 
  error is thrown from OLE).
 
  Some OLE calls require to be cast of a certain type before 
 they work.
 
  my $nodes = Variant(VT_ARRAY|VT_VARIANT, 0);

My apologies here..  I think that I misstated the way to call it. 

Put this at the top somewhere...

use Win32::OLE::Variant;

Add the following before your GetChildNodes call.  Thanks go to Michael
Ellery for making me see that mistake as I did not test this code before
sending it off.

my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0);

By adding this before your GetChildNodes call, you should be all set
(Variant-wise)

However, before you give up after trying the above call (if it does not
work as stated above), I would replace:

VT_ARRAY|VT_VARIANT 

With

VT_VARIANT 

And also try.. (if the previous does not work)

VT_ARRAY|VT_BSTR

And lastly try his example from the SecurityDescriptor call..

VT_DISPATCH|VT_BYREF

...in my code above.  

As well, you might try sticking the VT_BYREF as another ORed option to
each of the above examples like in Michael Ellery's example..  i.e.
VT_ARRAY_|VT_BSTR|VT_BYREF or VT_VARIANT|VT_BYREF or
VT_ARRAY|VT_VARIANT|VT_BYREF

HTH

Steven

 
  #I might also try VT_VARIANT or VT_ARRAY|VT_BSTR instead of 
  VT_ARRAY|VT_VARIANT
 
  #then
  my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, TRUE);
 
  Play around with this...  I'm not the greatest Variant 
 script writer 
  here, to know exactly which combination will work (if this is it) 
  based on the object type as I've only run into this a few times 
  before, but you can get examples from your perl install here 
  (depending on your perl build version) of similar options 
 to try and all the VT_* types:
 
  C:\Perl\html\lib\Win32\OLE\Variant.html
 
  HTH
 
  P.S. I googled OV_NodeGroup and found someone else with your same 
  problem on an HP board (or so it seems).  :(
 
  Steven
 
  ___
  Perl-Win32-Users mailing list
  Perl-Win32-Users@listserv.ActiveState.com
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
  ___
  Perl-Win32-Users mailing list
  Perl-Win32-Users@listserv.ActiveState.com
  To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
  
 
 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: WIN32::OLE WMI Out params

2009-12-04 Thread Michael
Okay - Just to sum up the whole thing.

The original VBScript EOF;

Option Explicit

Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes,
objItem

Set objWMIService = GetObject(winmgmts:root\HewlettPackard\OpenView\data)

Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup)
Set objGetRoot = objOV_NodeGroup.GetRoot()
objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True)

WScript.Echo Child Group Count:   objChildGroups  vbCrLF

For Each objItem In arrNodes
  WScript.Echo Name:   objItem.Name
Next
EOF

Returns the following:

Child Group Count: 25

Name: {36716FD8-E600-46FB-90CA-1263E0C62509}
Name: {38FF8E8E-2DDC-4895-A7EB-0DC7DF50EC25}
Name: {3E575181-0225-4553-9722-46F841B9FA76}
Name: {8A412133-F571-42BC-8A66-4B242EB3BAC4}
Name: {E14D965C-1FBB-40EC-A784-5F9F39F82281}
Name: OpenView_AIX
Name: OpenView_External
Name: OpenView_HPUX
Name: OpenView_Linux
Name: OpenView_NNM
Name: OpenView_OpenVMS
Name: OpenView_OpenVMS(itanium)
Name: OpenView_SNMP
Name: OpenView_Solaris
Name: OpenView_Tru64
Name: OpenView_Unknown
Name: OpenView_Windows2000
Name: OpenView_WindowsNT
Name: OpenView_WindowsServer2003
Name: OpenView_WindowsServer2008
Name: OpenView_WindowsVista
Name: OpenView_WindowsXP
Name: Root_Special
Name: Root_Unix
Name: Root_Windows

And the Perl-Script with the modification EOF;
#!perl
use strict;
use warnings;
use Win32::OLE qw(in with);
use Win32::OLE::Variant;
use Data::Dumper;

my $objWMIService =
Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or die
WMI connection failed.\n;
if (Win32::OLE- LastError() != 0) {
print Error calling GetObject:  . Win32::OLE-LastError() . \n;
exit 0;
}

my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup);
if (Win32::OLE- LastError() != 0) {
print Error calling Get:  . Win32::OLE-LastError() . \n;
exit 0;
}

my $objGetRoot = $objOV_NodeGroup-GetRoot();
if (Win32::OLE- LastError() != 0) {
print Error calling GetRoot:  . Win32::OLE-LastError() . \n;
exit 0;
}

my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0);
#my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF);
#my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0);
#my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF);
#my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);
#my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0);
#my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF);
#my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);

my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, True);
if (Win32::OLE- LastError() != 0) {
print Error calling GetChildNodeGroups:  . Win32::OLE-LastError() .
\n;
exit 0;
}
print Child Group Count:  . $objChildGroups . \n;

print Dumper($nodes);


foreach my $objItem (in $nodes) {
print 'Name: ' . $objItem-{Name} . \n;
}

#my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); Returns
##Child Group Count: 25
##$VAR1 = bless( do{\(my $o = 27197068)}, 'Win32::OLE::Variant' );
##Not a HASH reference at GetChildNodeGroups.pl line 46.

#my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns
##Child Group Count: 25
##$VAR1 = bless( do{\(my $o = 27197828)}, 'Win32::OLE::Variant' );
##Not a HASH reference at GetChildNodeGroups.pl line 46.

#my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); Returns
##Child Group Count: 25
##$VAR1 = bless( do{\(my $o = 27198308)}, 'Win32::OLE::Variant' );
##Not a HASH reference at GetChildNodeGroups.pl line 46.

#my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); Returns
##Error calling GetChildNodeGroups: Win32::OLE(0.1709) error 0x80010105:
The server threw an exception
##in METHOD/PROPERTYGET GetChildNodeGroups

#my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);
Returns
##Child Group Count: 25
##$VAR1 = bless( do{\(my $o = 27199076)}, 'Win32::OLE::Variant' );
##Not a HASH reference at GetChildNodeGroups.pl line 46.

#my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0);
Returns
##Child Group Count: 25
##$VAR1 = bless( do{\(my $o = 27197684)}, 'Win32::OLE::Variant' );
##Not a HASH reference at GetChildNodeGroups.pl line 46.

#my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns
##Child Group Count: 25
##$VAR1 = bless( do{\(my $o = 27199620)}, 'Win32::OLE::Variant' );
##Not a HASH reference at GetChildNodeGroups.pl line 46.

#my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);
Returns
##Child Group Count: 25
##$VAR1 = bless( do{\(my $o = 27199524)}, 'Win32::OLE::Variant' );
##Not a HASH reference at GetChildNodeGroups.pl line 46.

Does any of this, make any sense to you guys?

/Michael



___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: WIN32::OLE WMI Out params

2009-12-04 Thread Michael Ellery
Michael wrote:
 Okay - Just to sum up the whole thing.
 
 The original VBScript EOF;
 
 Option Explicit
 
 Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups, arrNodes,
 objItem
 
 Set objWMIService = GetObject(winmgmts:root\HewlettPackard\OpenView\data)
 
 Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup)
 Set objGetRoot = objOV_NodeGroup.GetRoot()
 objChildGroups = objGetRoot.GetChildNodeGroups(arrNodes, True)
 
 WScript.Echo Child Group Count:   objChildGroups  vbCrLF
 
 For Each objItem In arrNodes
   WScript.Echo Name:   objItem.Name
 Next
 EOF
 
 Returns the following:
 
 Child Group Count: 25
 
 Name: {36716FD8-E600-46FB-90CA-1263E0C62509}
 Name: {38FF8E8E-2DDC-4895-A7EB-0DC7DF50EC25}
 Name: {3E575181-0225-4553-9722-46F841B9FA76}
 Name: {8A412133-F571-42BC-8A66-4B242EB3BAC4}
 Name: {E14D965C-1FBB-40EC-A784-5F9F39F82281}
 Name: OpenView_AIX
 Name: OpenView_External
 Name: OpenView_HPUX
 Name: OpenView_Linux
 Name: OpenView_NNM
 Name: OpenView_OpenVMS
 Name: OpenView_OpenVMS(itanium)
 Name: OpenView_SNMP
 Name: OpenView_Solaris
 Name: OpenView_Tru64
 Name: OpenView_Unknown
 Name: OpenView_Windows2000
 Name: OpenView_WindowsNT
 Name: OpenView_WindowsServer2003
 Name: OpenView_WindowsServer2008
 Name: OpenView_WindowsVista
 Name: OpenView_WindowsXP
 Name: Root_Special
 Name: Root_Unix
 Name: Root_Windows
 
 And the Perl-Script with the modification EOF;
 #!perl
 use strict;
 use warnings;
 use Win32::OLE qw(in with);
 use Win32::OLE::Variant;
 use Data::Dumper;
 
 my $objWMIService =
 Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data) or die
 WMI connection failed.\n;
 if (Win32::OLE- LastError() != 0) {
   print Error calling GetObject:  . Win32::OLE-LastError() . \n;
 exit 0;
 }
 
 my $objOV_NodeGroup = $objWMIService-Get(OV_NodeGroup);
 if (Win32::OLE- LastError() != 0) {
   print Error calling Get:  . Win32::OLE-LastError() . \n;
 exit 0;
 }
 
 my $objGetRoot = $objOV_NodeGroup-GetRoot();
 if (Win32::OLE- LastError() != 0) {
   print Error calling GetRoot:  . Win32::OLE-LastError() . \n;
 exit 0;
 }
 
 my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0);
 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0);
 #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0);
 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF);
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);
 
 my $objChildGroups = $objGetRoot-GetChildNodeGroups($nodes, True);
 if (Win32::OLE- LastError() != 0) {
   print Error calling GetChildNodeGroups:  . Win32::OLE-LastError() .
 \n;
 exit 0;
 }
 print Child Group Count:  . $objChildGroups . \n;
 
 print Dumper($nodes);
 
 
 foreach my $objItem (in $nodes) {
 print 'Name: ' . $objItem-{Name} . \n;
 }
 
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT, 0); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27197068)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27197828)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR, 0); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27198308)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_DISPATCH|VT_BYREF); Returns
 ##Error calling GetChildNodeGroups: Win32::OLE(0.1709) error 0x80010105:
 The server threw an exception
 ##in METHOD/PROPERTYGET GetChildNodeGroups
 
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);
 Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27199076)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_BSTR|VT_BYREF, 0);
 Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27197684)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_VARIANT|VT_BYREF); Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27199620)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 #my $nodes = Win32::OLE::Variant-new(VT_ARRAY|VT_VARIANT|VT_BYREF, 0);
 Returns
 ##Child Group Count: 25
 ##$VAR1 = bless( do{\(my $o = 27199524)}, 'Win32::OLE::Variant' );
 ##Not a HASH reference at GetChildNodeGroups.pl line 46.
 
 Does any of this, make any sense to you guys?
 
 /Michael
 


so, it looks like your Dumper statement is indicating a valid object in
most cases. I think the problem on your loop is that you are using the
'in' adapter, 

RE: WIN32::OLE WMI Out params

2009-12-03 Thread Brian Raven
Michael  wrote:
 Hi,
 
 I'm a novice regarding Perl, and need some help converting a VBScript
 to a PerlScript. 
 
 The following VBScript returns some data from HP OpenView. The
 GetChildNodeGroups method returns the number of ChildGroups, 
 
 and the [out] parameter NodeGroups returns an array which contains a
 list of OV_NodeGroup. 
 
 From the documentation:
 
 sint32 GetChildNodeGroups(
   [out] OV_NodeGroup NodeGroups[],
   [in, optional] boolean IncludeSubGroups)
 
 Description
 Returns a list of node groups (instances of OV_NodeGroup) that are
 children of this node group. 
 
 Return Value
 Number of node groups (children) in the out parameter NodeGroups.
 
 ' VBScript Begin
 
 Option Explicit
 
 Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups,
 arrNodes, objItem 
 
 Set objWMIService =
 GetObject(winmgmts:root\HewlettPackard\OpenView\data) 
 
 Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set
 objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups =
 objGetRoot.GetChildNodeGroups(arrNodes, True)  
 
 WScript.Echo Child Group Count:   objChildGroups  vbCrLF
 
 For Each objItem In arrNodes
   WScript.Echo Name:   objItem.Name
 Next
 
 ' VBScript End
 
 The problem is that I can't find out how to get the array (@arrNodes)
 in Perl. 
 
 # PerlScript Begin
 use strict;
 use warnings;
 use Win32::OLE qw(in with);
 use Data::Dumper;
 
 my $objWMIService =
 Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data)
 or die WMI connection failed.\n; my $objOV_NodeGroup =
 $objWMIService-Get(OV_NodeGroup); my $objGetRoot =
 $objOV_NodeGroup-GetRoot();  
 
 my @arrNodes;
 
 my $objChildGroups = $objGetRoot-GetChildNodeGroups(@arrNodes,
 True); 

And you were doing so well up to this point. I really don't think that
you want to pass an empty array, interpolated into a string, as an
output parameter. In fact, I would expect that it might even produce a
run-time error. Does it?

I don't know the answer, but from my limited Perl/OLE experience, my
first guess would be that the function would want to return an OLE
container object in the output parameter, and so would expect it to be a
reference to a scalar. For example:

my $nodes;
use constant TRUE = 1;
my $objChildGroups = $objGetRoot-GetChildNodeGroups(\$nodes, TRUE);

 
 print Child Group Count:  . $objChildGroups . \n;
 
 print @arrNodes . \n;

If I am right, and I may well not be, this would probably need to be
something like:

for my $obj (in $nodes) {
print Name: $obj-{Name}\n;
}

 
 # PerlScript End
 
 Any help would be appreciated.

HTH, in lieu of somebody coming up with a more certain answer.

-- 
Brian Raven 
This e-mail may contain confidential and/or privileged information. If you are 
not the intended recipient or have received this e-mail in error, please advise 
the sender immediately by reply e-mail and delete this message and any 
attachments without retaining a copy.

Any unauthorised copying, disclosure or distribution of the material in this 
e-mail is strictly forbidden.

___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: WIN32::OLE WMI Out params

2009-12-03 Thread Michael
 Michael   wrote:
  Hi,
  
  I'm a novice regarding Perl, and need some help converting a VBScript
  to a PerlScript. 
  
  The following VBScript returns some data from HP OpenView. The
  GetChildNodeGroups method returns the number of ChildGroups, 
  
  and the [out] parameter NodeGroups returns an array which contains a
  list of OV_NodeGroup. 
  
  From the documentation:
  
  sint32 GetChildNodeGroups(
  [out] OV_NodeGroup NodeGroups[],
  [in, optional] boolean IncludeSubGroups)
  
  Description
  Returns a list of node groups (instances of OV_NodeGroup) that are
  children of this node group. 
  
  Return Value
  Number of node groups (children) in the out parameter NodeGroups.
  
  ' VBScript Begin
  
  Option Explicit
  
  Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups,
  arrNodes, objItem 
  
  Set objWMIService =
  GetObject(winmgmts:root\HewlettPackard\OpenView\data) 
  
  Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set
  objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups =
  objGetRoot.GetChildNodeGroups(arrNodes, True)  
  
  WScript.Echo Child Group Count:   objChildGroups  vbCrLF
  
  For Each objItem In arrNodes
WScript.Echo Name:   objItem.Name
  Next
  
  ' VBScript End
  
  The problem is that I can't find out how to get the array (@arrNodes)
  in Perl. 
  
  # PerlScript Begin
  use strict;
  use warnings;
  use Win32::OLE qw(in with);
  use Data::Dumper;
  
  my $objWMIService =
  Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data)
  or die WMI connection failed.\n; my $objOV_NodeGroup =
  $objWMIService-Get(OV_NodeGroup); my $objGetRoot =
  $objOV_NodeGroup-GetRoot();  
  
  my @arrNodes;
  
  my $objChildGroups = $objGetRoot-GetChildNodeGroups(@arrNodes,
  True); 
 
 And you were doing so well up to this point. I really don't think that
 you want to pass an empty array, interpolated into a string, as an
 output parameter. In fact, I would expect that it might even produce a
 run-time error. Does it?

Nope it does not. The problem is still that @arrNodes is empty. The
GetChildNodeGroups method does not populate the variable/array like it does
in VBScript. Therefore I've been around @arrNodes, \...@arrnodes, $nodes
etc...

 
 I don't know the answer, but from my limited Perl/OLE experience, my
 first guess would be that the function would want to return an OLE
 container object in the output parameter, and so would expect it to be a
 reference to a scalar. For example:
 
 my $nodes;
 use constant TRUE =  1;
 my $objChildGroups = $objGetRoot- GetChildNodeGroups(\$nodes, TRUE);
 
  
  print Child Group Count:  . $objChildGroups . \n;
  
  print @arrNodes . \n;
 
 If I am right, and I may well not be, this would probably need to be
 something like:
 
 for my $obj (in $nodes) {
 print Name: $obj- {Name}\n;
 }
 

Yep - but because $nodes/@arrNodes is empty this does not change much.

  
  # PerlScript End
  
  Any help would be appreciated.
 
 HTH, in lieu of somebody coming up with a more certain answer.
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: WIN32::OLE WMI Out params

2009-12-03 Thread Steven Manross
When troubleshooting OLE issues, it is best to have the following code
after each OLE command...

If (Win32::OLE-LastError() != 0) {
  print error calling blah:  . Win32::OLE-LastError() . \n;
  exit 0;
} 

...Or something similar, so you can see what OLE had issues with (if
anything).  It might lead you in a direction that fixes it.

Steven
 -Original Message-
 From: perl-win32-users-boun...@listserv.activestate.com 
 [mailto:perl-win32-users-boun...@listserv.activestate.com] On 
 Behalf Of Michael
 Sent: Thursday, December 03, 2009 6:19 AM
 To: perl-win32-users@listserv.ActiveState.com
 Subject: RE: WIN32::OLE WMI Out params
 
  Michael   wrote:
   Hi,
   
   I'm a novice regarding Perl, and need some help converting a 
  VBScript  to a PerlScript.
   
   The following VBScript returns some data from HP OpenView. The  
  GetChildNodeGroups method returns the number of ChildGroups,
   
   and the [out] parameter NodeGroups returns an array which 
 contains a  
  list of OV_NodeGroup.
   
   From the documentation:
   
   sint32 GetChildNodeGroups(
 [out] OV_NodeGroup NodeGroups[],
 [in, optional] boolean IncludeSubGroups)
   
   Description
   Returns a list of node groups (instances of OV_NodeGroup) 
 that are  
  children of this node group.
   
   Return Value
   Number of node groups (children) in the out parameter NodeGroups.
   
   ' VBScript Begin
   
   Option Explicit
   
   Dim objWMIService, objOV_NodeGroup, objGetRoot, objChildGroups,  
  arrNodes, objItem
   
   Set objWMIService =
   GetObject(winmgmts:root\HewlettPackard\OpenView\data)
   
   Set objOV_NodeGroup = objWMIService.Get(OV_NodeGroup) Set  
  objGetRoot = objOV_NodeGroup.GetRoot() objChildGroups =  
  objGetRoot.GetChildNodeGroups(arrNodes, True)
   
   WScript.Echo Child Group Count:   objChildGroups  vbCrLF
   
   For Each objItem In arrNodes
 WScript.Echo Name:   objItem.Name  Next
   
   ' VBScript End
   
   The problem is that I can't find out how to get the array 
  (@arrNodes)  in Perl.
   
   # PerlScript Begin
   use strict;
   use warnings;
   use Win32::OLE qw(in with);
   use Data::Dumper;
   
   my $objWMIService =
   
 Win32::OLE-GetObject(winmgmts:root/HewlettPackard/OpenView/data)
   or die WMI connection failed.\n; my $objOV_NodeGroup =  
  $objWMIService-Get(OV_NodeGroup); my $objGetRoot =  
  $objOV_NodeGroup-GetRoot();
   
   my @arrNodes;
   
   my $objChildGroups = $objGetRoot-GetChildNodeGroups(@arrNodes,
   True);
  
  And you were doing so well up to this point. I really don't 
 think that 
  you want to pass an empty array, interpolated into a string, as an 
  output parameter. In fact, I would expect that it might 
 even produce a 
  run-time error. Does it?
 
 Nope it does not. The problem is still that @arrNodes is 
 empty. The GetChildNodeGroups method does not populate the 
 variable/array like it does in VBScript. Therefore I've been 
 around @arrNodes, \...@arrnodes, $nodes etc...
 
  
  I don't know the answer, but from my limited Perl/OLE 
 experience, my 
  first guess would be that the function would want to return an OLE 
  container object in the output parameter, and so would 
 expect it to be 
  a reference to a scalar. For example:
  
  my $nodes;
  use constant TRUE =  1;
  my $objChildGroups = $objGetRoot- 
 GetChildNodeGroups(\$nodes, TRUE);
  
   
   print Child Group Count:  . $objChildGroups . \n;
   
   print @arrNodes . \n;
  
  If I am right, and I may well not be, this would probably 
 need to be 
  something like:
  
  for my $obj (in $nodes) {
  print Name: $obj- {Name}\n;
  }
  
 
 Yep - but because $nodes/@arrNodes is empty this does not change much.
 
   
   # PerlScript End
   
   Any help would be appreciated.
  
  HTH, in lieu of somebody coming up with a more certain answer.
 ___
 Perl-Win32-Users mailing list
 Perl-Win32-Users@listserv.ActiveState.com
 To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
 
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: WIN32::OLE WMI Out params

2009-12-03 Thread Michael
 When troubleshooting OLE issues, it is best to have the following code
 after each OLE command...
 
 If (Win32::OLE- LastError() != 0) {
   print error calling blah:  . Win32::OLE- LastError() . \n;
   exit 0;
 } 
 
 ...Or something similar, so you can see what OLE had issues with (if
 anything).  It might lead you in a direction that fixes it.
 
 Steven

Added to the script, but no issues reported.

/Michael
___
Perl-Win32-Users mailing list
Perl-Win32-Users@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs