t_rex_joe has asked for the wisdom of the Perl Monks concerning the following question:
eval { local $SIG{ALRM} = sub { warn "ALARM FOR GET WMIC L: \"" . __LINE_ +_ . "\" F: \"" . __FILE__ . "\"\n" }; # NB: \n required alarm 10; $wmicon = Win32::OLE->GetObject('winmgmts:' . '{impersonationLevel +=impersonate, authenticationLevel=pkt}!\\\\' . $host . '\\root\\CIMV2 +\sms') or $ok = 0; alarm 0; }; if($@){ $err = 1; $ret = "timeout while accessing wmi on machine $h +ost"; return($err, $ret); } else { } # didn't
The code above works as expected$col = undef; eval { local $SIG{ALRM} = sub { warn "ALARM FOR GET EXEC QUERY: \"$quer +y\" L: \"" . __LINE__ . "\" F: \"" . __FILE__ . "\"\n" }; # NB: \n re +quired alarm 5; $col = $wmicon->ExecQuery($query, "WQL", wbemFlagReturnImmediate +ly | wbemFlagForwardOnly | WbemAuthenticationLevelPkt) or $ok = 0; alarm 0; }; if($@){ $err = 1; $ret = "timeout while QUERY: \"$query\" wmi on +machine $host"; return($err, $ret); } else { } # didn't if($ok == 0) { $err = 1; $ret = clean(Win32::OLE->LastError); retu +rn($err, $ret); }
$objct = 0; $enabled = 0; $obj = undef; foreach $obj (in $col) { my $delete = 0; if($debug == 1) { print "\tOBJ: \"$obj\" L: \"" . __LINE__ . "\" +\n"; } }
my %colhash = % { $col }; if($debug == 1) { print "DUMP COLHASH: \"" . Dumper(%colhash) . "\" +L: \"" . __LINE__ . "\"\n"; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Problem enumerating a foreach loop using Win32::OLE->GetObject
by hexcoder (Curate) on Apr 12, 2018 at 16:15 UTC | |
by t_rex_joe (Sexton) on Apr 12, 2018 at 18:52 UTC | |
by Discipulus (Canon) on Apr 12, 2018 at 19:42 UTC | |
by t_rex_joe (Sexton) on Apr 13, 2018 at 18:23 UTC | |
Re: Problem enumerating a foreach loop using Win32::OLE->GetObject
by Discipulus (Canon) on Apr 12, 2018 at 16:21 UTC | |
Re: Problem enumerating a foreach loop using Win32::OLE->GetObject
by afoken (Chancellor) on Apr 12, 2018 at 20:20 UTC |