in reply to Re: Perl $ENV hash
in thread Perl $ENV hash

corion-
I have domain admin privileges. how can I makes sure, i have WMIC libraries installed. Is this defauly?
I ran perldoc WIN32::WMI but it said no docs found. so I am assuming lib not loaded.
can you help me get started on where to look for the lib or if its already installed.
THanks.

Replies are listed 'Best First'.
Re^3: Perl $ENV hash
by Corion (Patriarch) on Apr 20, 2010 at 14:10 UTC
      what is wrong here. nothing is printing to the file, list.txt
      #use warnings; #use DBI; use Win32; use Win32::OLE qw (in); open(HLOG,">c:/temp/logf.txt") || die " Open Log_file: $!"; open(HLIST,">C:/temp/list.txt") || die " Open list.txt: $!"; #my $dbh = DBI->connect('dbi:DBI:'); while(<>) { chomp($_); @a = `ping -n 1 $_`; print "for $_:"; if ("@a" =~ /Request timed out/i || "@a" =~ /could not find host/i + ){ print "<<<<not Alive>>>>>\n"; #TODO #spit it to non-alive txt file #close file print(HLOG); } else { print "::: Alive\n"; my $Class = "WinMgmts://$_"; my $Wmi = Win32::OLE->GetObject ($Class); if ($Wmi) { my %Vars = $Wmi->ExecQuery("SELECT * FROM $Win32_Environme +nt"); print $Vars; foreach (keys %Vars) { print HLIST $Vars{$_} ."\n"; } } else { print "NO idea"; } #TODO: if alive, check if cadmap exists, if yes, spit the var= +value pair to a log.txt file. } } close (HLOG) || die "Close: $!"; close (HLIST) || die "Close:$!";

        You are not using the strict pragma. If you had done so, Perl would have forced you to declare all variables you use. That would have shown you that there is no variable declared with the name $Win32_Environment, but you try to use it in your string.