The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #4 (permalink)  
Old 07-06-2007
caddyjoe77 caddyjoe77 is offline
Registered User
 

Join Date: Apr 2005
Posts: 28
Quote:
Originally Posted by aigles View Post
Code:
foreach($computer, @raw_list)
{
   $objWMIService = Win32::OLE->GetObject
       ("winmgmts:\\\\$computer\\root\\CIMV2") or die "WMI connection failed.\n";
   $colItems = $objWMIService->ExecQuery
       ("SELECT * FROM Win32_OperatingSystem","WQL",wbemFlagReturnImmediately | wbemFlagForwardOnly);

   foreach my $objItem (in $colItems)
   {
         print "Caption: $objItem->{Caption}\n";
         print "CSD Version: $objItem->{CSDVersion}\n";
         print "CS Name: $objItem->{CSName}\n";
         print "Name: $objItem->{Name}\n";
         print "Service Pack Major Version: $objItem->{ServicePackMajorVersion}\n";
         print "System Directory: $objItem->{SystemDirectory}\n";
         print "Windows Directory: $objItem->{WindowsDirectory}\n";
         print "\n";
   }
}

I tried that and get a 255 error.

if i change it to foreach(@raw_list) or foreach($computer) i get an error 9

here is the error, substitute 255 for the 9

WMI connection failed.
host1
host2
host3
Exit code: 9 , 0009h

I'm sure it is with the array, but damn if i can figure it out! Where do i find the system error codes such as 9 or 255?

EDIT: ok, i ran the script with perl -w and this is what i received

Odd number of elements in hash assignment at retina.pl line 21, <DATA> line 3.
Win32::OLE(0.1707) error 0x80041021
after character 0 in "winmgmts:\\c:\list\hosts.txt
\root\CIMV2" at retina.pl line 30
eval {...} called at retina.pl line 30
WMI connection failed.


so basically, what i gather from this is that it may not even be connecting to the WMI service to begin with? And for some reason it is reading what is supposed to be a hostname as the literal filename and path. Am i on the right track here?

thank you

Last edited by caddyjoe77; 07-06-2007 at 04:00 AM. Reason: ran with perl -w to report errors....wanted to update post instead of making a reply to me; answering yourself means insanity
Reply With Quote