Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: unpacking wmic command's unicode output

by goibhniu (Hermit)
on Nov 11, 2008 at 19:53 UTC ( #722963=note: print w/ replies, xml ) Need Help??


in reply to Re: unpacking wmic command's unicode output
in thread unpacking wmic command's unicode output

That's a good idea and I may resort to that. I had it in my head to get this piped from the output. Can I open a pipe as UTF-16?

Update: I was thinking of a syntax like:
wmic process | find /i "myprog.exe" | getmyfields.pl


#my sig used to say 'I humbly seek wisdom. '. Now it says:
use strict;
use warnings;
I humbly seek wisdom.


Comment on Re^2: unpacking wmic command's unicode output
Download Code
Re^3: unpacking wmic command's unicode output
by BrowserUk (Pope) on Nov 11, 2008 at 19:59 UTC

      So it DOES! Thank you, thank you, O sage. I'd have been weeks in perlpacktut were it not for this elegant solution!


      #my sig used to say 'I humbly seek wisdom. '. Now it says:
      use strict;
      use warnings;
      I humbly seek wisdom.
      I don't get the -CS. Does wmic really output UTF-8? Wouldn't it be more appropriate to use wmic process | perl script.pl?
        Does wmic really output UTF-8?

        It appears it does (some form of unicode anyway), if you redirect its output to a file (or via a pipe):

        c:\test>wmic.exe process > junk c:\test>u:head -c 200 junk  ■C a p t i o n C o m m a n d L i n +e

        That first spludge(*) is the LE BOM 0xfffe. (It was a spludge when I c&p'd it!)

        Probably utf-16le I think, but whatever it is, using -CS does seem to cause perl to work out what it is getting and treat it appropriately:

        c:\test>wmic.exe process | perl -CS -pe1 > junk c:\test>u:head -c 200 junk Caption CommandLine

        Whether by accident or design, it is useful.


        Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
        "Science is about questioning the status quo. Questioning authority".
        In the absence of evidence, opinion is indistinguishable from prejudice.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://722963]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (14)
As of 2014-07-11 14:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    When choosing user names for websites, I prefer to use:








    Results (227 votes), past polls