in reply to unpacking wmic command's unicode output
I wrestled with wmic a while back and came up with a very perl-friendly way to access the data.
The key is using list /format:value on the command line.
-Craig
use strict; use Tk; use Data::Dumper; my %DATA; # Get info via wmic (not available on all versions of windows)... my @data = split(/^\s*\cM\n/m, `wmic process list /format:value`); shift(@data); pop(@data); # Remove first/last blank lines my %procs; # Iterate through each element... foreach my $p (@data) { $p =~ s/\cM//g; # Grrrr, rotten windows my %child = split(/[=\n]/, $p); # Hashify information $procs{$child{ProcessId}} = \%child; } print Dumper(\%procs), "\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: unpacking wmic command's unicode output
by goibhniu (Hermit) on Nov 13, 2008 at 20:38 UTC |