On 2023-04-11 08:43, Andrey Repin via Cygwin wrote:
Greetings, Leonid Mironov!
I am trying to feed the output of wmic.exe - a windows console program, to
cygwin bash script.
wmic.exe produces UTF16LE output with BOM and CR/LFs, so I am using dos2unix to
convert it.
The problem is that when I write wmic.exe output to a file and then use
dos2unix to convert this file
I get the expected result - ASCII file with LFs, I get the same result when I
pipe this file to dos2unix,
but when I pipe wmic.exe output directly to dos2unix I get ASCII file with
CR/LFs and an extra empty line.
Cygwin is up to date, windows 10. What gives?
You don't need d2u. Use `… | iconv -f UTF16LE | tr -d '\r'`
(Don't even need -t for iconv - it assumes current locale settings as
default source/destination encoding.)
d2u -ul converts from utf-16le to utf-8
When I run wmic under mintty or | less it looks fine to me e.g.:
$ wmic baseboard list full | less # optional
but the output could benefut from \r stripping:
$ wmic baseboard list full | tr -d '\r' | cat -A | less
https://learn.microsoft.com/en-us/windows/whats-new/deprecated-features#deprecated-features
The WMIC tool is deprecated in Windows 10, version 21H1 and the 21H1 General
Availability Channel release of Windows Server. This tool is superseded by
Windows PowerShell for WMI.
https://learn.microsoft.com/en-us/powershell/scripting/learn/ps101/07-working-with-wmi
--
Take care. Thanks, Brian Inglis Calgary, Alberta, Canada
La perfection est atteinte Perfection is achieved
non pas lorsqu'il n'y a plus rien à ajouter not when there is no more to add
mais lorsqu'il n'y a plus rien à retirer but when there is no more to cut
-- Antoine de Saint-Exupéry
--
Problem reports: https://cygwin.com/problems.html
FAQ: https://cygwin.com/faq/
Documentation: https://cygwin.com/docs.html
Unsubscribe info: https://cygwin.com/ml/#unsubscribe-simple