Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re^11: unpacking wmic command's unicode output

by BrowserUk (Pope)
on Nov 12, 2008 at 21:50 UTC ( #723299=note: print w/replies, xml ) Need Help??


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

As a solution, it's useless and therefore wrong.

Hm. That's a bit strong. As a solution, it produces the desired result. Ie. The data in the file is sans unicoding.

The fact that the -CS isn't actually responsible for that--nor even perl itself directly--doesn't detract from the usability of the solution to produce desired result.

As it turns out, wmic process | perl -pe1 > file also produces the desired result, and as its 3 characters shorter I guess that makes it a superiour solution. I would have suggested that; had I thought to have tried it.

It turns out that it just going via a pipe that causes wmic.exe to produce ansi output rather than unicode, so a simple wmic process | tee > file works.

And it's even shorter.


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.

Replies are listed 'Best First'.
Re^12: unpacking wmic command's unicode output
by ikegami (Pope) on May 12, 2015 at 15:19 UTC
    I suspect that wmic always outputs the same thing, but that tee uses ReadFileA forcing a recoding to "ANSI".
Re^12: unpacking wmic command's unicode output
by pwatson (Initiate) on May 11, 2015 at 15:02 UTC
    Why does Perl leave double CRs?
    C:>wmic diskdrive where "model = 'HGST HTS725050A7E630 ATA Device'" ge +t index | perl -pe1 >x3.txt 8:54:20.49 C:\Users\pwatson C:>odd x3.txt 000000 49 6e 64 65 78 20 20 0d 0d 0a +30 20 20 20 20 20 I n d e x \r \r \n 0 000010 20 0d 0d 0a 0d 0d 0a \r \r \n \r \r \n
      Why does Perl leave double CRs?

      I've no idea where they come from, but it isn't Perl. This produces the same effect:

      E:\Chart>wmic diskdrive where "Partitions = 1" get index | tee > junk. +txt E:\Chart>od -xa junk.txt 0000000 6e49 6564 2078 0d20 0a0d 2032 2020 2020 I n d e x sp sp cr cr nl 2 sp sp sp sp s +p 0000020 0d20 0a0d 2030 2020 2020 0d20 0a0d 0d0d sp cr cr nl 0 sp sp sp sp sp sp cr cr nl cr c +r 0000040 000a nl nul 0000041

      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      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". I'm with torvalds on this
      In the absence of evidence, opinion is indistinguishable from prejudice. Agile (and TDD) debunked

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (4)
As of 2018-11-17 04:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My code is most likely broken because:
















    Results (202 votes). Check out past polls.

    Notices?